Chris Pollett > Students >

    ( Print View )


    [Project Blog]











    [Project Code-TAR GZ]


Chess Game Databases and GNU Chess Program

Description: Researched and understood how external chess game databases can be used with GNU chess program. Chess game databases come in .PGN format. PGN format file is converted into .dat format by running GNUchess command. Once the database is converted into book.dat format, GNUchess consults the book for any moves. If it finds an appropriate matching move, it uses that move otherwise the program calculates the next best move using the PVS chess algorithm.

Example 1: Integrating grandmaster Anand Vishwanathan's 2106 games:

Add Anand.pgn

In Example 1 I compiled grandmaster Anand Vishwanathan's 2106 games and converted it into book.dat format used by GNUchess program. The book.dat is a binary file written in network byte order. GNUchess program reads the complete game database into memory where the HashType is uint64_t. Based upon the given board position the program generates all the possible moves and filters illegal moves. Each unique move from the book.dat are stored in following temporary datastructure : static unsigned char buf[2+2+2+8]; where buf represents wins, losses, draws, key for a particular move. This buf is then stored in the bookpos array of pointers to structures that represents wins, losses, draws and key for each move. The match for the next move is called the DIGEST_MATCH. There is a possibility of more than one match. The move it picks is based upon number of wins with that move. It is also configurable how it picks the move - best, wost, random and so on.


Example 2: Using moves from grandmaster Anand Vishwanathan's 2106 games:

Move from book.dat

Example 2 shows the command line output of running the GNUchess program with book.dat game database. Here the program finds five possible moves. It picks move 'Nf6' because it is the best move.

Example 3: Unable to use moves from grandmaster Anand Vishwanathan's 2106 games:

Move from PVS algorithm

In Example 3 the GNUchess program could not find any move from book.dat. Hence it applies the PVS algorithm to find the next best move.