Author: Robert Hyatt
Date: 17:52:10 05/07/04
Go up one level in this thread
On May 07, 2004 at 19:51:42, Uri Blass wrote:
>I looked at the code of Crafty to understand what it does when it creates the
>opening book(the function BookUp()).
>
>1)I see that it it is using malloc to allocate memory.
>I have no malloc in movei and I use calloc to allocate hash tables.
>
>I find that Crafty has no calloc but many malloc and my question is if there is
>a reason for that.
Nope. Just a long-time C programmer using what he has been using for 25+ years.
:)
>
>2)I understand that crafty first translate pgn to book positions but I do not
>see moves in the following structs
>
>typedef struct {
> BITBOARD position;
> unsigned int status_played;
> float learn;
> int CAP_score;
>} BOOK_POSITION;
>
>typedef struct {
> unsigned char position[8];
> unsigned char status;
> unsigned char percent_play;
>} BB_POSITION;
I don't store moves. I make a move and store the resulting 64 bit hash
signature only...
>
>
>My question is where does Crafty save the moves.
I don't. In a given position, I make a move, which updates the hash signature.
If that signature is found in the book file, then that move is a "book move". I
repeat for all legal moves and therefore produce the set of known book moves...
>
>I remember that I read that another program (Tao) save only positions in the
>book but it seems to me a bad idea for reasons that Dieter gave because the
>program may go to a book position instead of playing a better move.
>
>book should include positions and moves.
Perhaps. There is a solution. If the before-the-move position is not in the
book, but the after-the-move position is, then you are taking a slight risk to
go back into book without searching to see if there is anything better...
>
>3)If I understand correctly Crafty first remember the book in a big array and
>only later sort the big array by BookSort and later copy it to a file.
>
>I do not understand what BookUpNextPosition does and what reason there is to
>return the least (lexically) position key.
It forces all book positions with the same "parent" position to be adjacent in
the book file. Now I don't have to randomly probe all over the book to find if
a particular move leads to a known book position. I index to the "cluster" that
contains all of those positions with a common parent position, and read that in
once and search thru it for each possible move from this position. This is
mainly to make it very fast..
>
>If I want to put a new position in the book I need to put it in the right place
>and I do not understand how the least hash key can help me.
>
>
>Uri
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.