I am currently working on a chess engine in Java. I am using the minimax algorithm with alpha-beta pruning to select the best move. However, it is inefficient to use the algorithm for selecting opening moves.

So here is my question for people who have experience with making their own engines:

How do you make your own opening book? Do you create your own database to store different openings and their successive variations? Or is their a general database that one can connect to and extract moves?

I would gladly appreciate any help from anyone who has experience or knowledge on this.


It may depend a little on what your code can access, but either way you should read Ed Schröder's pages on this topic. Schröder was the author of the Rebel Chess software until his retirement about a decade ago. In the '90s Rebel was the strongest consumer/commercial chess software and the first such to beat a GM (Anand). Since retiring he turned Rebel into ProDeo and released it for free on his website.

Start with this introduction, though you should already know all that, then have a look at this more in depth explanation. Then check this page for details on adding Rebel/ProDeo books to any engine (will require compiling C code for each platform you want your engine to be able to work). You should be able to add to the books from PGN records before compiling them.

EDIT: Not quite sure why this was voted down, but probably the mention of C when the OP states Java. I should mention that most chess processing software is in C or C++ because it provides better processing capabilities; it compiles to assembly language or machine code, unlike Java, which requires the JVM to run and that makes Java less efficient. Yes, it is possible to compile Java into machine code, but hardly anyone ever does it because then it is no longer platform independent (such as it is). So the OP will be running into the C hurdle no matter what.

Beyond that, these sites on the chess programming wiki on opening books and opening suites may be of use. You'll find a bunch of Ed Scröder's stuff there because he is one of the pioneers who made the shift from hardware electronic chess systems (e.g. Mephisto) to personal computing software. With the added bonus that now he's giving his software and, more importantly, his knowledge away to whoever wants it. If that's really not enough to immerse one's self in the subject then nothing is.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.