Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Crafty BIN book format:

Author: Nicolas Carrasco

Date: 20:02:14 11/08/99

Go up one level in this thread


Thanks for your detailed answer.

On November 08, 1999 at 15:01:13, Robert Hyatt wrote:

>On November 07, 1999 at 22:50:26, Nicolas Carrasco wrote:
>
>>Hi guys,
>>
>>I guess how is the Crafty book position format,Is there any Documentation?
>>
>>Thanks
>
>
>This is not really hard.  two pieces of data:
>
>(1) the 'book hash signature' is unusual.  If you take the hash signature
>before you make a book move, and the hash signature after you make a book
>move, you have the stuff you need.  I take the upper 16 bits of the hash
>signature _before_ making the move, and combind with the lower 48 bits of
>the hash signature _after_ the book move is made.  I do this so that all
>book moves from the same 'parent' position have the same upper 16 bits.
>(actually, other book moves from different parent positions may have the
>same 16 bits, but that is unimportant.  The main point is that from a position
>P, all the successor positions will be different in the right-most 48 bits, but
>identical in the leftmost 16 bits.
>
>(2) I sort these hash signatures in simple ascending order after I parse the
>entire (huge) PGN input file.  This collects all moves from the same parent
>together.
>
>The first 32K words in the book file are indices to groups of moves with the
>same upper 15 bits (I don't use all 16 at present, simply to reduce the size of
>this 'index' by a factor of two).  Each of these indices points further into the
>book file to a 'cluster'.  A cluster has (a) a count (number of moves in the
>cluster, which is the number of moves which have the same upper 16 bits) and
>then one entry for each book position.
>
>To find known book positions, I do this:
>
>1.  take the upper 15 bits of current (before book moves tried) hash
>signature and read that specific index from the front of the file (15
>bits means 0 <= N < 32768).  That index points into the book file to the
>'cluster'.  Seek to that byte and read the int there, which is the number
>of moves in that 'cluster'.
>
>2.  for each move in the move list, make one, and compare the rightmost 48 bits
>of the resulting hash signature with the rightmost 48 bits of the hash signature
>in the book file.  If you get an exact match, the move you just tried is a valid
>book move.
>
>After you do that, pick from the moves you found, based on whatever you want to
>use for selection rules.
>
>Look at chess.h, "BOOK_POSITION" to see what is in the book entry besides the
>hash signature...
>
>I wrote the book like this as it lets me do one I/O to read in the entire
>'cluster' and get all the possible book moves for the current position.  I don't
>have to do N seek/reads to find if a move is a book move or not..



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.