Polyglot opening book specification

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
krazyken

Re: Polyglot opening book specification

Post by krazyken » Tue Nov 11, 2008 10:46 pm

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: 2210
Joined: Sun Sep 28, 2008 11:50 pm

Re: Polyglot opening book specification

Post by Michel » Tue Nov 11, 2008 11:02 pm

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: 2210
Joined: Sun Sep 28, 2008 11:50 pm

Re: Polyglot opening book specification

Post by Michel » Tue Nov 11, 2008 11:14 pm

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 5:45 pm
Location: Finland
Contact:

Re: Polyglot opening book specification

Post by ilari » Wed Nov 12, 2008 12:56 am

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 9:05 pm
Contact:

Re: Polyglot opening book specification

Post by Marc Lacrosse » Wed Nov 12, 2008 7:06 am

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 » Wed Nov 12, 2008 3:15 pm

Thanks Marc! That will help immensely.

Alessandro Scotti

Re: Polyglot opening book specification

Post by Alessandro Scotti » Wed Nov 12, 2008 7:55 pm

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 9:05 pm
Contact:

Re: Polyglot opening book specification

Post by Marc Lacrosse » Wed Nov 12, 2008 8:37 pm

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

One more !

Marc

Michel
Posts: 2210
Joined: Sun Sep 28, 2008 11:50 pm

Re: Polyglot opening book specification

Post by Michel » Fri Nov 14, 2008 9:37 am

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: 2210
Joined: Sun Sep 28, 2008 11:50 pm

Re: Polyglot opening book specification

Post by Michel » Fri Nov 14, 2008 9:44 am

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

Post Reply