亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stone.c

?? 該程序是C語言編寫的
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*----------------------------------------------------*- Fundamental -*-

Facility:		stone(6)

File:			stone.c

Associated files:	- (none)

Description:		Plays the game of Kalah.

Notes:			This program was originally available in two
			versions, one for dumb terminals and ttys
			(stone) and one for H19-type terminals
			(hstone).  The present version is a cleaned-
			up implementation of hstone, adapted for a
			curses-compatible terminal interface.

			The program will only work on terminals with
			at least 80 chars per line, and with at least
			24 lines.  The only reason for this limit
			is the screen layout - see printb()

Portability:		Edited to conform to X/Open Portability
			Guide, ed. 3

Authors:		Terry Hayes & Clark Baker
			Real-Time Systems Group
			MIT Lab for Computer Science

Editor:			Leor Zolman

			Anders Thulin
			Rydsvagen 288
			S-582 50 Linkoping
			SWEDEN

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Edit history :

Vers  Ed   Date	       By               Comments
----  ---  ----------  ----------------  -------------------------------
 1.0    0  19xx-xx-xx  Hayes & Baker
 1.1    1  19xx-xx-xx  Leor Zolman
 1.2    2  1990-03-25  Anders Thulin

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/*---  Configuration options:  ----------------------------------------

System configuration options:
=============================

  ANSI		ANSI C
  BSD		BSD Unix, SunOS 3.5
  SV2		AT&T UNIX System V.2
  XPG3		X/Open Portability Guide, ed. 3

If you have an ANSI C conformant compiler, define ANSI.  If not, choose
the definition that most closely matches your environment.


Program configuration options:
==============================

  TRACE		This definition should not be changed. It is used to
		remove all code that in the original version wrote
		tracing information to the screen. As these completely
		destroy the screen layout they have been removed.

		A good way of including them in the program would be to
		change them to write to a special trace window. This is
		left as an exercise for the reader.

  BEEP		See 'comments' below

  FUDGE (65)	Used to determine the total number of game tree nodes
		(game positions) to be examined -- computed as

		  FUDGE * chosen level of difficulty

  MAX_LEVEL (1000)

		The maximum level of difficulty allowed. FUDGE * MAX_LEVEL
		should not be larger than INT_MAX.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#define	ANSI	1
#define	BSD	0
#define	SV2	0
#define	XPG3	0

#define	TRACE	0	
#define	BEEP()		beep()

#define	FUDGE		32
#define	MAX_LEVEL	1000

/* - - end of configuration options - - - - - - - - - - - - - - - - - - - */

#if ANSI
# include <ctype.h>
# include <curses.h>
# include <stdio.h>
# include <stdlib.h>
 extern int getopt(int argc, char *argv[], char optstring[]);
 extern int optind;
#endif

#if BSD
# include <ctype.h>
# include <curses.h>
# include <stdio.h>
 extern int getopt();
 extern int optind;
#endif

#if SV2
# include <ctype.h>
# include <curses.h>
# include <stdio.h>
 extern int getopt();
 extern int optind;
#endif

#if XPG3
# include <ctype.h>
# include <curses.h>
# include <stdio.h>
# include <stdlib.h>
 extern int getopt();
 extern int optind;
#endif

/*--- Comments on known problems: ------------------------------------------

curses

  Some older implementation of curses does not have the beep()
  function, which beeps at the user.

  On such systems, you may need to define BEEP to produce a
  beep in some other way, like fputc(0x07, stderr).

  If you cannot beep at all, try to flash the screen.

  If you cannot do either, just define BEEP to be empty, which is
  permitted behaviour for curses' beep().

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

/*--- Original notes on the program:  -----------------------------------

"STONE"
(otherwise known as "Awari")

This version written by
	Terry Hayes & Clark Baker
	Real-Time Systems Group
	MIT Lab for Computer Science
(and hacked up a little by Leor Zolman)

The algorithm used for STONE is a common one to Artificial Intelligence
people: the "Alpha-Beta" pruning heuristic. By searching up and down a tree
of possible moves and keeping record of the minimum and maximum scores from
the terminal static evaluations, it becomes possible to pinpoint move
variations which can in no way affect the outcome of the search.  Thus,
those variations can be simply discarded, saving expensive static evaluation
time. 

#if TRACE

To have the program print out some search statistics for every move
evaluation, type the command as

  A> stone -d

To also see a move-by-move trace of each terminal evaluation, type

  A> stones -a

#end 

THIS is the kind of program that lets C show its stuff; Powerful expression
operators and recursion combine to let a powerful algorithm be implemented
painlessly. 

And it's fun to play!

Rules of the game:

Each player has six pits in front of him and a "home" pit on one side (the
computer's home pit is on the left; your home pit is on the right.)

At the start of the game, all pits except the home pits are filled with n
stones, where n can be anything from 1 to 6. 

To make a move, a player picks one of the six pits on his side of the board
that has stones in it, and redistributes the stones one-by-one going
counter-clockwise around the board, starting with the pit following the one
picked.  The opponent's HOME pit is never deposited into. 

If the LAST stone happens to fall in that player's home pit, he moves again. 

If the LAST stone falls into an empty pit on the moving player's side of
board, then any stones in the pit OPPOSITE to that go into the moving
player's home pit. 

When either player clears the six pits on his side of the board, the game is
over.  The other player takes all stones in his six pits and places them in
his home pit.  Then, the player with the most stones in his home pit is the
winner. 

The six pits on the human side are numbered one to six from left to right;
the six pits on the computer's side are numbered one to six right-to-left. 

The standard game seems to be with three stones; less stones make it
somewhat easier (for both you AND the computer), while more stones
complicate the game.  As far as difficulty goes, well...it USED to be on a
scale of 1 to 50, but I couldn't win it at level 1.  So I changed it to
1-300, and couldn't win at level 1.  So I changed it to 1-1000, and if I
STILL can't win it at level 1, I think I'm gonna commit suicide. 

Good Luck!!!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Notes added by Anders Thulin:

The present program plays the game of Kalah.  It does not play the game of
Oware, which has slightly more complicated rules.  For a description of
Oware (as well as other games of the Mancala family), take a look at Ian
Lennox-Smith's series of articles in the British magazine Games & Puzzles,
no. 26-29 (July-October 1974), or any reliable book on board games (there
*are* unreliable ones!)

Kalah is usually played with 3-6 stones in each pit. The game with only one
stone in each pit is 'trivial' (won by the first player), as well as that
with two stones. It is reasonably easy to modify this program to check this
statement out. 

There is an interesting paper on a learning implementation of Kalah in
Machine Intelligence vol. 3, ed. D. Michie, Edinburgh 1974. The paper is
written by A. G. Bell; the title is 'Kalah on Atlas'.

For a description of the alpha-beta pruning algorithm, see almost any
introductory work on artificial intelligence. A good description is given by
David Levy in The Chess Computer Handbook, Batsford, London 1984.

For an interesting description of different minimax algorithms (including
the alpha-beta algorithm) see the article 'A Comparison of Minimax Tree
Search Algorithms' by Murray S. Campbell and T.A. Marsland in the journal
Artificial Intelligence, vol. 20 (1983), p. 347-367. This paper describes a
slightly 'better' alpha-beta algorithm, compared to that used in this
program.

Finally, the author of the original comments makes a peculiar statement in
his last lines in regard to the difficulty level of the program.

Changing the maximum difficulty level from 50, to 300, to 1000 does not
change the level of play on level 1. It only changes the size of the game
tree that is being examined.  The level number corresponds to the number of
positions (nodes) that should be examined.  Playing at level 1 always gives
the same performance, regardless of the maximum number of levels.

However, if you find that level 1 is too difficult, change the FUDGE
parameter above; it is used to determine the final number of nodes.  A FUDGE
factor of 1 (or even 0) makes for the easiest play.

I do really hope that he did discover this in time ...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

#define	NR_PITS		6	
#define	BOARD_SIZE	(2*(NR_PITS+1))

#ifndef TRUE			/* should be defined in <curses.h> */
# define  TRUE		1
# define  FALSE		0
#endif

#define	MAX(i, j)	((i) > (j) ? (i) : (j))
#define	MIN(i, j)	((i) < (j) ? (i) : (j))

#define	P_FIRST		1			/* Player's first pit	*/
#define	P_KALAH		(P_FIRST+NR_PITS)	/* Player's kalah	*/
#define	C_FIRST		(P_KALAH+1)		/* Computer's first pit	*/
#define	C_KALAH		0			/* Computer's kalah	*/

typedef	char t_board[BOARD_SIZE];

/*----------------------------------------------------------------------
  Local variables:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

int	 DEPTH;		/* The current depth of the playing tree 	*/
int	 MAXDEPTH;	/* The max depth reached during evaluation	*/
unsigned CALLS;		/* ??? Same as WIDTH ???			*/
unsigned TOTDEPTH;	/* ... */
unsigned WIDTH;		/* Total number of nodes evaluated		*/
unsigned TERM;		/* ... */
unsigned COUNT;		/* The max number of nodes to be examined	*/
int      NUM;		/* Nr of stones per pit at beginning of game	*/

int	pbegins;	/* true if player moves first	*/

unsigned total;		/* nr of moves actually considered		*/

#if TRACE
/*  Command line options:	*/

int      ab;		/* TRUE if printouts of ... */
int	 db;		/* TRUE if printouts of ... */

#endif /* TRACE */

/*----------------------------------------------------------------------
  Local routines:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#if __STDC__ != 0
 static int  comp(char *board);
 static int  comp1(char *board, int who, unsigned count, int alpha, int beta); 
 static int  countnodes(char *board, int start); 
 static int  dmove(char *new, int move);
 static int  done(char *board);
 static void get_game_parameters(void);
 static int  get_players_move(char *board);
 static void initb(t_board board);
 static int  mmove(char *old, char *new, int mov);
 static int  mod(int i, int j);
 static void printb(t_board board);
#else
 static int  comp();
 static int  comp1(); 
 static int  countnodes(); 
 static int  dmove();
 static int  done();
 static void get_game_parameters();
 static int  get_players_move();
 static void initb();
 static int  mmove();
 static int  mod();
 static void printb();
#endif

/*----------------------------------------------------------------------

Routine:	dmove

Description:	Perform a move and print out the resulting board.
		Return TRUE or FALSE depending on whether the
		move was a continuation move or not (see mmove)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

static int dmove(new, mov)
char *new;
int   mov;
{
  int i;
  i = mmove(new,new,mov);
  printb(new);
  return(i);
}

/*----------------------------------------------------------------------

Routine:	done

Description:	Returns TRUE if any side is out of stones

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

static int done(board)
char *board;
{
  int c_stones;		/* Stones in computer's pits 	*/
  int p_stones;		/* Stones in player's pits	*/
  int i;

  c_stones = p_stones = 0;

  for (i=0; i<NR_PITS; i++) {
    p_stones += board[P_FIRST+i];
    c_stones += board[C_FIRST+i];
  }

  return (p_stones == 0) || (c_stones == 0);
}

/*----------------------------------------------------------------------

Routine:	get_game_parameters

Description:	ask user for various param values

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

static void get_game_parameters()
{
  char string[80];
  int  i;

  i = 17;
  while (i < LINES) {
    move(i, 0); clrtoeol();
    i++;
  }

  /*  1.  Choose difficulty level:	*/

  do {
    move(18, 0); printw("Enter difficulty level (1-%d): ", MAX_LEVEL);
    clrtoeol(); refresh();
    if ( getstr(string) == ERR) {
      printw("Error: getstr() returns error\n");  
    }
    i = atoi(string);
    if (i<1 || i>MAX_LEVEL) {
      printw("Error: level %d is out of range!\n", i);
    }
  } while (i<1 || i>MAX_LEVEL);;

  COUNT = i * FUDGE;

  /*  2.  Choose number of stones:	*/

  do {
    move(19, 0); addstr("Number of stones : "); clrtoeol();
    refresh();
    if (getstr(string) == ERR) {
      printw("Error: getstr() returns ERR\n");
    }
    i = atoi(string);
    if (i < 1) {
      printw("Error: can't play with %d stones!\n", i);
    }
  } while (i < 1);;
  NUM = i;

  /*  3.  Choose who's first to move:	*/

  do {
    move(20, 0); addstr("Do you want to go first (y or n)? "); clrtoeol();
    refresh();
    getstr(string);
    i = toupper(string[0]);
    if (i != 'Y' && i != 'N') {
      addstr("Please input 'y' or 'n'!\n");
    }
  } while (i != 'Y' && i != 'N');
  pbegins = (i == 'Y');

  /*  4.  Remove the questions:  */

  move(18, 0); clrtoeol();
  move(19, 0); clrtoeol();
  move(20, 0); clrtoeol(); 
}

/*----------------------------------------------------------------------

Routine:	get_players_move

Description:	requests a legal move from the user, and returns
		it as function value.

		legal moves for the user is in the range 
		1..NR_PITS.

		If the user enters a 'q' the special move -1
		is returned.

Problems:	The atoi() routine does not set errno on all systems.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

static int get_players_move(board)
char *board;
{
  char  string[80];
  int	p_move;

  p_move = 0;
  while (p_move == 0) {
    move(20, 0); addstr("Your move: "); clrtoeol();
    refresh();
    getstr(string);
    if (toupper(string[0]) == 'Q') {
      p_move = -1;
    } else {
      p_move = atoi(string);
      if (p_move < 1 || p_move > NR_PITS || board[p_move] == 0) {
        addstr("Illegal!!"); BEEP();
        p_move = 0;
      }
    }
  }
  move(21, 0); clrtoeol();	/* remove any remaining 'Illegal!' lines */

  return p_move;
}

/*----------------------------------------------------------------------

Routine:	main

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */

int main(argc,argv)
int   argc;
char *argv[];
{
  int	pmove;		/* player's latest move		*/
  int	cmove;		/* computer's latest move	*/

  int	hum;		/* user's score		*/
  int	com;		/* program's score	*/

  t_board board;	/* game board		*/

  int	i;		/* scratch variables	*/
  int	errflag;
  int	c;
  char	string[100];

#if TRACE

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美女孩性生活视频| 91同城在线观看| 日本亚洲视频在线| 亚洲成av人**亚洲成av**| 亚洲一区二区四区蜜桃| 曰韩精品一区二区| 亚洲综合久久av| 亚洲国产日韩a在线播放性色| 亚洲一区二区五区| 日本v片在线高清不卡在线观看| 五月婷婷综合在线| 久久精品av麻豆的观看方式| 久久99精品久久久久久久久久久久| 蜜桃精品在线观看| 福利一区二区在线观看| 91在线无精精品入口| 欧美午夜精品理论片a级按摩| 欧美专区在线观看一区| 欧美一区二区高清| 久久精品视频在线看| 中文字幕亚洲精品在线观看 | 国产午夜亚洲精品理论片色戒| 精品国产一二三| 国产精品二区一区二区aⅴ污介绍| 中文字幕永久在线不卡| 亚洲一二三四区不卡| 美女尤物国产一区| eeuss鲁一区二区三区| 在线观看欧美黄色| 久久精品视频网| 一区二区三区丝袜| 美女爽到高潮91| 91浏览器在线视频| 欧美不卡一区二区| 亚洲精品一卡二卡| 久久er精品视频| 91麻豆6部合集magnet| 日韩欧美色综合| 一区二区三区成人| 国产精品自拍av| 欧美日韩美少妇| 欧美国产日韩一二三区| 亚洲国产精品久久一线不卡| 国产在线视频不卡二| 欧美三级日本三级少妇99| 久久理论电影网| 天堂久久久久va久久久久| 粉嫩久久99精品久久久久久夜| 欧美二区三区91| 亚洲美女视频在线观看| 国产成人精品亚洲日本在线桃色| 欧美色综合影院| 国产精品久久久久久久久免费丝袜| 日韩激情视频网站| 欧美在线视频日韩| 中文字幕中文字幕一区| 国产精品66部| 日韩欧美自拍偷拍| 香蕉影视欧美成人| 欧美中文字幕不卡| 日韩理论片一区二区| 国产精品18久久久久久久久| 欧美一卡2卡3卡4卡| 亚洲国产欧美在线人成| 在线亚洲人成电影网站色www| 欧美激情一区二区在线| 国产一区二区三区国产| 久久综合九色综合97_久久久| 日韩精品电影在线| 欧美一区二区在线视频| 亚洲123区在线观看| 欧美丝袜丝nylons| 一区二区三区久久| 色播五月激情综合网| 亚洲男女一区二区三区| 99v久久综合狠狠综合久久| 中文字幕欧美激情一区| 成人性生交大合| 中文字幕在线观看不卡视频| 成人av在线一区二区| 中文字幕一区在线观看视频| caoporn国产精品| 亚洲精品一二三四区| 欧美日韩中文精品| 丝袜亚洲另类丝袜在线| 欧美一级欧美一级在线播放| 青青草精品视频| 精品久久久久久综合日本欧美| 国产麻豆日韩欧美久久| 欧美精品一区二区三| 国内不卡的二区三区中文字幕| 国产亚洲一区二区三区在线观看| 国产精品综合视频| 成人欧美一区二区三区黑人麻豆| 91视频你懂的| 奇米色777欧美一区二区| 久久嫩草精品久久久久| av中文字幕不卡| 亚洲一区二区三区美女| 欧美电影免费提供在线观看| 国产成人av在线影院| 亚洲精品国产a| 欧美一区二区精品在线| 国产不卡在线一区| 性久久久久久久久久久久| 久久婷婷国产综合国色天香 | 亚洲一区二区三区精品在线| 日韩一级免费观看| 成人av在线电影| 天天免费综合色| 国产亚洲综合av| 欧美日韩高清不卡| 国产99久久久国产精品潘金网站| 一区二区三区蜜桃网| 精品久久五月天| 91成人在线精品| 国产麻豆精品在线| 偷拍日韩校园综合在线| 中文字幕乱码一区二区免费| 欧美日韩第一区日日骚| 成人精品gif动图一区| 免费在线观看成人| 亚洲精品一二三四区| 久久久精品综合| 在线成人高清不卡| 91在线观看美女| 国产精品一品二品| 日韩精品久久理论片| 亚洲女人****多毛耸耸8| 久久久蜜桃精品| 日韩欧美亚洲国产精品字幕久久久| 99精品1区2区| 成人黄色av网站在线| 韩国欧美一区二区| 日韩精品电影在线观看| 亚洲自拍欧美精品| 综合分类小说区另类春色亚洲小说欧美| 欧美一区二区在线免费观看| 欧美在线观看视频在线| 91在线一区二区三区| 福利一区在线观看| 丁香天五香天堂综合| 韩国成人精品a∨在线观看| 日韩电影免费在线观看网站| 亚洲成人tv网| 亚洲电影你懂得| 午夜在线电影亚洲一区| 一区二区不卡在线视频 午夜欧美不卡在 | 国产成人av一区| 国产成人免费av在线| 粉嫩绯色av一区二区在线观看| 狠狠狠色丁香婷婷综合久久五月| 日韩中文字幕区一区有砖一区| 亚洲精品欧美在线| 一区二区三区欧美久久| 亚洲美女免费在线| 一区二区久久久久久| 亚洲夂夂婷婷色拍ww47| 亚洲精品国产视频| 亚洲国产综合色| 五月天激情综合| 麻豆精品在线观看| 国产专区综合网| av在线不卡网| 在线观看中文字幕不卡| 欧美男人的天堂一二区| 欧美精品在线视频| 欧美mv日韩mv国产网站app| 欧美草草影院在线视频| 欧美极品美女视频| 亚洲嫩草精品久久| 午夜精品视频一区| 国产一区中文字幕| 色综合网色综合| 欧美欧美午夜aⅴ在线观看| 欧美va亚洲va在线观看蝴蝶网| 国产色产综合色产在线视频| 亚洲欧美一区二区不卡| 午夜精品在线视频一区| 精东粉嫩av免费一区二区三区| 国产成人午夜片在线观看高清观看| 91在线你懂得| 日韩一区二区免费在线观看| 日本一区二区三区四区| 亚洲在线视频网站| 国产真实乱偷精品视频免| 91亚洲国产成人精品一区二三 | 蜜臀91精品一区二区三区| 国产一区二区视频在线播放| 99国产精品久久| 日韩一级片网址| 亚洲美女屁股眼交3| 久久99精品久久久久久久久久久久 | 成人app软件下载大全免费| 欧美色综合天天久久综合精品| 精品日韩av一区二区| 亚洲免费观看高清完整| 国产一区二区主播在线| 欧美四级电影网| 亚洲欧洲国产专区|