⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 一款运行在linux上的象棋游戏。用GTK/GNOME环境下用GLADE开发。
💻
📖 第 1 页 / 共 2 页
字号:
READMEGNU CHESS 5by Stuart Cracraft <cracraft@gnu.org>copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 19931994, 1995, 1996, 1997, 1998, 1999, 2000, 2001Modified Simon Waters <simon@wretched.demon.co.uk> 2001Modified Simon Waters <simon@wretched.demon.co.uk> 2003IMPORTANT: Please send all updates to Simon at the above address.Table of Contents  Introduction  Who We Are  Data Structures  Move Generator  Search  Evaluation  Book  Hash Table  Auxillary File Formats (PGN, EPD)  Universal Board  Caveats  Compilers  Internet  Xboard/Winboard  Command ListINTRODUCTIONWelcome to the GNU CHESS 5 README. This is somewhat different than a normal readme. You might consider this a manual. We've always foundmultiple documents confusing, overlapping and sometimes contradictoryas far as software documentation goes. By putting it all together inone place we hope to avoid these traditional inadequacies and be ableto maintain a single document. If you add documentation, add it tothis document only.GNU Chess 5 is the new version of GNU Chess. The goal of creating thisnew version was to eliminate perceived problems with past versions, themajor one being spaghetti-code that was extremely poorly documented, butanother being antiquated data structures and especially the ignominouslinked list. Another good reason was to have more standard file formatsfor game positions and game listings.WHO WE AREWe are the GNU Chess developers and you may reach us at 	bug-gnu-chess@gnu.orgWe are indebted to our sponsor, the Free Software Foundationwhose web page is:	http://www.gnu.organd which also serves as our software depository for new versions ofGNU and GNU Chess.We also have a Usenet bulletin board, gnu.chess. Feel free to post andsupport. Please become a developer and contribute your time and coding skillto GNU Chess. Make a donation of your time and money.But, as developers we like to develop our own ideas. Thus, if you havean idea check to see that no one else is working on it (posting on theabove bulletin board or sending an email should be sufficient to findif someone is working on the idea and if you can collaborate withthem.)We don't like messages asking us to implement features. Everybodyhas a list a mile long. Instead, contribute by writing code or pointingout very clearly a bug. To report a bug, tell us the version numberof the program ("./gnuchess --version").The code is provided for the purpose of encouraging you to do theprogramming.  If you lack the programming skills to do so, trydabbling in it. You might surprise yourself.DATA STRUCTURESThe primary data structure of GNU Chess is the bitboard. A bitboardis a 64-bit GNU C long long. It represents characteristics of a position.For example, 12 bitboards are sufficient to describe the whereaboutsof all the pieces for both sides, i.e.	BitBoard board.b[2][6];So for example with a knight equal to 2 and white equal to 0 all theknights are located by the reference	#define white 0	#define knight 2	... board.b[white][knight] ...Testing whether a particular square has a knight on it could be donewith 	if (BitBoard[B1] & board.b[white][knight]) { ... }Another set of move arrays is helpful for calculating the simple movesof a knight or a king	MoveArray[knight or king][sq]This returns a bitmap of the squares from which a knight or kingcould move from the square sq. Squares are based at 0 for a1 (White'squeen's rook 1) and numbered left to right up until 63 for h8 (Black'sking's rook 1).Another basic data structure is the board. It is defined in common.has the Board typedef:  typedef struct   {     BitBoard b[2][7];		/* Pieces by side (0 - white, 1 black				   by piece (1 - pawn ... 6 - king */     BitBoard friend[2];	/* Friendly (this side's) pieces */     BitBoard blocker;		/* Enemy pieces */     BitBoard blockerr90;     BitBoard blockerr45;     BitBoard blockerr315;     short ep;			/* Location of en passant square */     short flag;		/* Relevant flags relating to castle privs */     short side;		/* Color of side on move 0 - white 1 - black */     short material[2];		/* Total material by side not inc. king */     short pmaterial[2];	/* Total pawn material by side not inc. king */     short castled[2];		/* True (1) if side is castled */     short king[2];		/* Location of king 0 - a1 .. 63 - h8 */  } Board; Basic data structure typedefs are defined in common.h and allocated inmain.c for the most part. Please read and understand those files. Thebest way to understand data structures is to add new evaluation terms.MOVE GENERATORThis is a rotated bit-board method which is considered state-of-the-artcurrently.SEARCHBased on Professor Tony Marsland's modification to alpha-beta minimax,called Principal Variation Search (PVS), this algorithm performs credibly.EVALUATIONEvaluation in this version is quite a bit different than before.Earlier versions used piece/square tables with some end-leafevaluation (but primary pc/sq tables). These are tables filled withvalues regarding the importance of having pieces on particular squares.It was filled once, at the beginning of the search.The drawback of pc/sq tables is that the information is typically ofless and less importance the deeper a program searches because theboard changes so much. With computers getting faster and faster, deeperand deeper searches are possible and so the pc/sq tables can providemisleading direction to the program, resulting in anti-positional moves.More recently there has been a return by some to what we espouse here:full end-leaf evaluation. Further, we use bitboards (64-bit quantities)to represents characteristics of the board. This harkens back, ironicallyto the early days of computer chess when giant number-crunching machinesback in the 60's used bitmaps to describe positions.Bitboards in this version of GNU are defined using the "BitBoard" typedefdefined in common.h. main.c contains most of the bitboards and theseare accessed and used throughout the program and particularly bythe move generator and the evaluator.The evaluator in eval.c consists of a series of scoring routines likeScoreP (), ScoreN (), ScoreB (), corresponding to the piece beingscored. The routine evaluates all pieces of that type (P - pawn,N - knight, B - bishop, etc.) on the current board and returns ascore.Typically a loop is used of the form    short sq;	/* Location of the piece of this type */    short s;	/* Score value for all pieces    BitBoard b;	/* Stores the bitboard representing location of the piece */    s = 0;	/* Score starts out as zero */    b = board.b[side][knight];    while (b) {      sq = leadz(b);      CLEARBIT (b, sq);      if (piece on sq has some property)	s += SOME_BONUS_OR_PENALTY;    /* defined in eval.h */    }    return(s);As you can see, this routine locates each piece in the 64-bit mapwhere the corresponding square of the 64 is set to 1 meaning a pieceis there. Hence for example in the opening position, board.b[white][bishop]would have the 3rd and 7th low-order bits set corresponding to the originallocations of bishops in a game on C1 and F1. Likewise the valuesBitPosArray[C1] and BitPosArray[F1] can be used to return 64-bitquantities for checking specific matches as in   if (BitPosArray[A1] & board.b[side][bishop])	s += SOME_VERY_NEGATIVE_PENALTY_FOR_BISHOP_IN_A1_CORNERWriting evaluation code comes very naturally using these methods. Tryto avoid too many specific square checks as those are expensive. Ideasas shown in the CTL() routine can be used to check for piece placementon specific squares being advantageous or disadvantageous.Primary evaluation is done with Evaluate(). Certain specifics arecalculated which are deemed very important such as king evaluationand pawn evaluation. Then a "lazy evaluation" scenario is checkedfor which can save time. Otherwise other pieces are also evaluated.Very important for evaluation is the ability to see what board youare evaluating. Typically this should be sufficient when you addthe new term:	/* ... new logic ... */	{	  s += SOME_NEW_BONUS (define in eval.h)	  printf("The condition is triggered:\n");	  ShowBoard ();	  getchar();	}This lets you see the board at the point the condition is triggeredwhich adds the bonus or penalty to the evaluation score.BOOKThe opening book is implemented as a simple binary file consisting ofa set of sequential records of struct hashtype as defined in the modulebook.c. This data structure is simply two part, a 64-bit HashType (seecommon.h) and a 32-bit score. The binary book stored in book.dat is compiled from the file book.pgnusing the command "book add book.pgn" into a sequential set of binary records in the format as described above. book.pgn is simply a set of game records in portable game notation format.  A set of master games may be used or specific openings programmed this way for a user-changeableopening book.HASH TABLEThe hash table is simply an area of memory where information aboutpositions is stored. In this version of the program there are twotypes of hash tables: general and pawn. The general hash table size is controlled by the variable HASHSLOTSas defined in common.h. Likewise the pawn hash table size is controlledby the variable PAWNSLOTS in common.h.The number of hashtable slots can be controlled from the commandline (Type "gnuchess -help" for details), or via the interactive

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -