Polyglot opening book specification

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

krazyken

Re: Polyglot opening book specification

Post by krazyken »

Michel wrote:
I did not see mention of color support in the book spec. So with this format it is not possible to specify opening to be played only as white?
I don't quite understand what you mean. The color is encoded in the position.
Can you explain?
Which line I play depends on what color I have. Say for instance as white, I only play 1. e4. Other possible moves such as 1. d4 or 1. c4, need to be in the book because I need to know how to respond to them as black, but I would never play them as white.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Polyglot opening book specification

Post by Michel »

Once again a new version. There are no changes in the specs but one
of the test keys was wrong (a copying error).

I have now independently verified them.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Polyglot opening book specification

Post by Michel »

Say for instance as white, I only play 1. e4. Other possible moves such as 1. d4 or 1. c4, need to be in the book because I need to know how to respond to them as black, but I would never play them as white.
Ok I understand.

In PG you would set the weights of d4 and c4 equal to zero.

In fact it seems to me that strictly speaking d4 and c4 do not need to be in the
book at all. Only the positions resulting from these moves. I do not like this
very much though. It makes it harder (if not impossible) to dump the book in a human readable format.

I think PG has the concept of a white only and a black only book. I need to check
what this means.

Regards,
Michel
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: Polyglot opening book specification

Post by ilari »

Wow, thanks a bunch, Michel! I don't see myself directly using Polyglot books in Sloppy or my other projects, but now that there are clear specs I might add import and export support for them.
Marc Lacrosse
Posts: 511
Joined: Wed Mar 08, 2006 10:05 pm

Re: Polyglot opening book specification

Post by Marc Lacrosse »

Michel wrote:
Say for instance as white, I only play 1. e4. Other possible moves such as 1. d4 or 1. c4, need to be in the book because I need to know how to respond to them as black, but I would never play them as white.
I think PG has the concept of a white only and a black only book. I need to check
what this means.

Regards,
Michel
Yes, you have the switches "-only-white" and "-only-black" for book-making.

So for this example it is very easy :
1. you make a PGN containing only 1.e4 games (with your favored lines) and you make a "white.bin" book with "-only-white"
2. you make another pgn with all your favored answers to all white first move possibilities : "black.bin"
3. you do "PG.exe merge-book -in1 white.bin -in2 black.bin -out mybook.bin"

All my books are made of at least six different elementary books that I merge in one final book.
There are always elementary books for the white and black sides.
This process is extremely powerful when you combine these switches with the "-minscore" and "-min-games" ones to further differentiate elementaty books.

Possibilities are infinite.

This whole process makes polyglot much superior to any other book-making utility IMHO.

Marc
krazyken

Re: Polyglot opening book specification

Post by krazyken »

Thanks Marc! That will help immensely.
Alessandro Scotti

Re: Polyglot opening book specification

Post by Alessandro Scotti »

Great job Michel, Hamsters can use Polyglot books now! :-)

The only thing that was not clear to me is how to lookup entries in the book, and I had to take a look at source code for that. Fortunately it's a very short function and easy to understand.
Marc Lacrosse
Posts: 511
Joined: Wed Mar 08, 2006 10:05 pm

Re: Polyglot opening book specification

Post by Marc Lacrosse »

Alessandro Scotti wrote:Great job Michel, Hamsters can use Polyglot books now! :-)
Nice !

One more !

Marc
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Polyglot opening book specification

Post by Michel »

I have now included some sample code in the specification

* pg_key.c: This little utility computes the PG key of a FEN. Note that it does ZERO error checking on the legality of the FEN and hence will segfault if something is wrong.
* pg_show.c: This utility looks up a PG key in a PG book and prints out the moves and their (relative) weights.

This code is released in the public domain.

As always, look here

http://alpha.uhasselt.be/Research/Algebra/Toga/

Regards,
Michel
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Polyglot opening book specification

Post by Michel »

Alessandro Scotti (Alessandro Scotti) wrote
Great job Michel, Hamsters can use Polyglot books now! Smile
Fantastic. Good to know that my work has already had some use.

ilari (Ilari Pihlajisto) wrote
Michel! I don't see myself directly using Polyglot books in Sloppy or my other projects
Well perhaps you can make your engine understand PG books, even it is not your native format? As you can see from the (public domain) sample code I posted it is very little work.

Regards,
Michel