Creating an Opening Book for Maverick
Maverick is the first chess engine I’ve written which can use its own opening book. I decided at an early stage Maverick would read Polyglot opening books. It makes so much sense. Polyglot seems to be a great tool create opening books and its format seems to be emerging as the de-facto opening book standard.
So now I need to actually create an opening book. I did some research on the internet and it really is quite straightforward. Here are the steps I took:
- There are some really good free tools which you’ll need to download:
- Polyglot (the program which will generate the book)
- SCID the freeware PGN database tool
- PGN-Extract which cleans PGN files
- Opening Book Batch file and Filter I created
- You will also need a database of high quality game. I used Ed Schroeder’s Million Base. Make sure your database is in PGN format.
- Open the MillionBase using SCID.
- We’ll be filtering the games using SCID’s excellent filtering system – select “Search / Header…” (Ctrl-Shift-H)
- I created a database consisting of only White wins by players over 2400 ELO with opponents over 2200 ELO (see diagram)
- I then saved the white win database as “white2400.pgn” using SCID’s “Tools / Export All Filter Games” command
- Repeat for Black
- Now put both PGN files in the same folder as Polyglot.exe, PGN-Extract.exe, the batch file.
- The batch file contains the commands to create the opening book
pgn-extract -s -C -N -V -tstartpos.txt -oclean-white2400.pgn white2400.pgn polyglot make-book -only-white -pgn clean-white2400.pgn -bin w1.bin -max-ply 16 -min-game 50 polyglot make-book -only-white -pgn clean-white2400.pgn -bin w2.bin -max-ply 60 -min-game 5 polyglot merge-book -in1 w1.bin -in2 w2.bin -out w12.bin pgn-extract -s -C -N -V -tstartpos.txt -oclean-black2400.pgn black2400.pgn polyglot make-book -only-black -pgn clean-black2400.pgn -bin b1.bin -max-ply 16 -min-game 50 polyglot make-book -only-black -pgn clean-black2400.pgn -bin b2.bin -max-ply 60 -min-game 5 polyglot merge-book -in1 b1.bin -in2 b2.bin -out b12.bin polyglot merge-book -in1 w12.bin -in2 b12.bin -out Maverick.bin Pause 0
- The first line runs PGN-Extract and simply cleans the database, removing and games which don’t start from the normal starting position.
- The second line creates a opening book of white moves, where the positions have occurred at least 50 times.
- The third line creates a broader book which give more responses to a variety of openings.
- This is repeated for Black
- Finally all of the books are merged
The final opening book is a little over 1 Mb (it’s available on the download page)- quite small by most standards. I’ll need to run some test to see how good it is compared to other Polyglot books.
If there are any opening book specialists out there I’d appreciate any feedback. Can the process of creating the book be improved?