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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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精品国产全国免费观看| 亚洲视频免费看| 日韩精品一区二区三区swag | 99视频在线精品| 国产老肥熟一区二区三区| 精品福利视频一区二区三区| 国产亚洲人成网站| 国产真实乱偷精品视频免| 日韩av二区在线播放| 9191国产精品| av影院午夜一区| 国产一区二区三区在线观看精品| 久久久影院官网| 欧美日韩免费电影| 天天综合网天天综合色| 欧美一区二区三区系列电影| 亚洲人成在线观看一区二区| 免费观看久久久4p| 日本在线不卡一区| 97久久超碰国产精品| 色综合久久久久久久久| 国产乱一区二区| 国产精品理伦片| 色综合激情久久| 欧美日韩亚洲另类| 精品中文字幕一区二区小辣椒 | 色吊一区二区三区| 中文子幕无线码一区tr| 国产欧美视频在线观看| 日本韩国视频一区二区| 亚洲第一成人在线| 国产成人精品一区二| 国产视频不卡一区| 6080亚洲精品一区二区| 国产精品少妇自拍| 春色校园综合激情亚洲| 在线一区二区三区| 91在线国内视频| 日韩一二三区不卡| 一区二区三区高清在线| 免费观看日韩电影| 丰满亚洲少妇av| 欧美日韩精品欧美日韩精品一| 日韩欧美国产一区在线观看| 91国偷自产一区二区开放时间| 国产性做久久久久久| 精品伊人久久久久7777人| 精品国产乱码久久久久久久久| 欧美性感一区二区三区| 天堂va蜜桃一区二区三区漫画版| av资源站一区| 最新国产の精品合集bt伙计| www亚洲一区| 欧美成人vr18sexvr| 免费久久精品视频| 国产亚洲美州欧州综合国| 一区二区三区国产豹纹内裤在线| 亚洲成a人v欧美综合天堂| 一区二区三区在线视频观看58| 亚洲bt欧美bt精品777| 亚洲电影视频在线| 99re66热这里只有精品3直播 | 日韩一级大片在线观看| 视频一区二区中文字幕| 91美女片黄在线| 久久精品999| 欧美电影一区二区| 蜜臀av性久久久久蜜臀av麻豆| 91久久精品一区二区三区| 国产成人亚洲综合a∨婷婷| 国产欧美日韩在线| 美女网站在线免费欧美精品| 成人动漫视频在线| 国产精品人成在线观看免费| 国产成人丝袜美腿| 亚洲国产日日夜夜| 婷婷开心激情综合| 国产精品一区一区| 91免费观看在线| 日韩美女视频一区二区| 国产精品毛片无遮挡高清| 最新国产精品久久精品| 亚洲欧美综合网| 国内精品国产成人国产三级粉色| www.亚洲色图.com| 欧美日本韩国一区二区三区视频| 国产人成亚洲第一网站在线播放 | 波多野结衣一区二区三区| 欧美96一区二区免费视频| 成人午夜视频在线观看| 久久久久九九视频| 中文字幕乱码一区二区免费| 日韩影院在线观看| 在线视频你懂得一区二区三区| 奇米亚洲午夜久久精品| 视频一区视频二区中文字幕| 国内精品久久久久影院薰衣草| 成人av综合一区| 成人午夜免费视频| 日韩免费在线观看| 日韩一区二区三区免费观看| 91精品午夜视频| 中文字幕一区二区三区不卡| 国产色婷婷亚洲99精品小说| 成人毛片在线观看| 国内偷窥港台综合视频在线播放| 亚洲一二三四区| 日韩精品乱码免费| 99精品久久只有精品| 丁香亚洲综合激情啪啪综合| 欧美一区二区免费视频| 精品一区二区三区免费毛片爱 | 精品国产麻豆免费人成网站| 久久久久99精品国产片| 精品奇米国产一区二区三区| 亚洲欧美色综合| 一区二区三区 在线观看视频| 7777精品伊人久久久大香线蕉| 欧美日本免费一区二区三区| 欧美一卡2卡三卡4卡5免费| fc2成人免费人成在线观看播放| www.亚洲色图| 久久综合色一综合色88| 亚洲午夜私人影院| 欧美色图天堂网| 成人一道本在线| 久久99国产精品麻豆| 亚洲精品中文在线观看| 久久久99精品免费观看| 久久国产综合精品| 日韩一区二区在线看片| 日韩精品电影在线观看| 色综合久久综合网欧美综合网 | 国产喷白浆一区二区三区| 欧美日韩一区久久| 免费日韩伦理电影| 2023国产精华国产精品| 久久er99热精品一区二区| 一区二区三区波多野结衣在线观看| 久久久亚洲精品石原莉奈| 在线看日本不卡| 国产精品成人在线观看| 麻豆久久久久久久| 久久久777精品电影网影网 | 国产精品夜夜嗨| 美女在线视频一区| 日日摸夜夜添夜夜添精品视频| 亚洲精品videosex极品| 日韩理论片在线| 日韩精品一区二区三区在线| 国产精品99久| 国内精品久久久久影院薰衣草| 蜜臀久久久久久久| 国产视频一区二区三区在线观看| 毛片基地黄久久久久久天堂| 欧美高清dvd| 色综合久久中文综合久久牛| 成人网在线免费视频| 天堂在线一区二区| 亚洲日本青草视频在线怡红院| 国产精品免费视频观看| 国产精品九色蝌蚪自拍| 国产精品国产精品国产专区不蜜| 成人激情免费视频| 亚洲高清在线精品| 国产欧美一区视频| 日韩欧美国产综合在线一区二区三区| 日韩视频一区在线观看| 亚洲国产成人91porn| 成人国产一区二区三区精品| av在线不卡免费看| 欧美一区二区三区在线视频| 日韩欧美一级片| 亚洲欧美激情小说另类| 亚洲电影激情视频网站| 日本午夜精品视频在线观看| 一区二区理论电影在线观看| 国产自产视频一区二区三区| 亚洲丝袜美腿综合| 中文无字幕一区二区三区| 国产精品剧情在线亚洲| 一区二区三区波多野结衣在线观看 | 欧美手机在线视频| 在线电影院国产精品| 性做久久久久久| 国产日本一区二区| 蜜桃久久久久久| 午夜电影一区二区| 欧美国产精品一区二区| 国产亚洲精品精华液| 亚洲精品高清视频在线观看| 欧美一级片在线观看| 99热精品国产| 欧美成人一区二区三区片免费 | 色综合久久中文综合久久97| 成人免费av资源| 91精品视频网| 久久精品国产在热久久| 精品一区二区三区的国产在线播放|