Openning Book for Chess Engine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

yodatk
Posts: 16
Joined: Mon Oct 26, 2020 2:49 pm
Full name: Tomer Gonen

Openning Book for Chess Engine

Post by yodatk »

Hello everyone, I Have been working on a chess engine for a while now
(with the help of this amazing toturial:
And now I want to add a book support for my engine to make it's games a bit more fluid and diverse.
I want it to be able to use it's own book even when not playing in arenna.

What is the best way to include an opening book in the Chess Engine?
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Openning Book for Chess Engine

Post by mvanthoor »

Polyglot is the default for most engines. Look into this:



(Tutorial by BlueFever Software, author of the chess engine VICE. Many people learned the basics from this tutorial, and many engines are based on, or inspired by Vice, uncluding the one you're linking to.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
OfekShochat
Posts: 50
Joined: Thu Oct 15, 2020 10:19 am
Full name: ghostway

Re: Openning Book for Chess Engine

Post by OfekShochat »

I think the best way is polyglot books. it is faster than just reading a pgn file and you do that with zobrist hashing.
hope it helps!
if you have another question post around! :D
yodatk
Posts: 16
Joined: Mon Oct 26, 2020 2:49 pm
Full name: Tomer Gonen

Re: Openning Book for Chess Engine

Post by yodatk »

Thank you both! you helped a lot!
User avatar
phhnguyen
Posts: 1437
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Openning Book for Chess Engine

Post by phhnguyen »

yodatk wrote: Tue Oct 27, 2020 8:46 am Hello everyone, I Have been working on a chess engine for a while now
(with the help of this amazing toturial:
And now I want to add a book support for my engine to make it's games a bit more fluid and diverse.
I want it to be able to use it's own book even when not playing in arenna.

What is the best way to include an opening book in the Chess Engine?
Except you are an opening book developer/planning to create your own opening books, and/or having some special ideas... friendly speaking, don’t add the code for opening books to your engine since the benefit so little, compared with the labor. Many users, testers consider that is the job of chess GUIs and they may be not happy if your engine is stuck with just a “normal” opening book.

If you still want for your private use/testing, I suggest to use an EPD or PGN book. It is far more easier to write code, embed data to the engine as well as to edit the book content than to use/code for a Polyglot book.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
yodatk
Posts: 16
Joined: Mon Oct 26, 2020 2:49 pm
Full name: Tomer Gonen

Re: Openning Book for Chess Engine

Post by yodatk »

phhnguyen wrote: Thu Oct 29, 2020 1:39 am
yodatk wrote: Tue Oct 27, 2020 8:46 am Hello everyone, I Have been working on a chess engine for a while now
(with the help of this amazing toturial:
And now I want to add a book support for my engine to make it's games a bit more fluid and diverse.
I want it to be able to use it's own book even when not playing in arenna.

What is the best way to include an opening book in the Chess Engine?
Except you are an opening book developer/planning to create your own opening books, and/or having some special ideas... friendly speaking, don’t add the code for opening books to your engine since the benefit so little, compared with the labor. Many users, testers consider that is the job of chess GUIs and they may be not happy if your engine is stuck with just a “normal” opening book.

If you still want for your private use/testing, I suggest to use an EPD or PGN book. It is far more easier to write code, embed data to the engine as well as to edit the book content than to use/code for a Polyglot book.
hey there,
I totally agree it's the job of the gui... when your engine is comepeting against other engines.
In my case, I have a different version of my engine playing in Lichess as a bot player where real players could play against is too.
(you can try it too https://lichess.org/@/NissimEngine )

without an opening book , if a player want to play against my engine let's say a rapid game of 15+10 game, it might take my engine somthing like 2 minutes to replay on the first move. (which is not that great of a user expirience). when adding an opening book -the game become more fluid, and the engine starts "thinking" only in after 4-5 moves which makes more sense.

of course that when I am testing in Arena, I am using the GUI book too.
Thanks for your reply!
User avatar
phhnguyen
Posts: 1437
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Openning Book for Chess Engine

Post by phhnguyen »

The solution is so simple: add an opening book to your bot management (but not your engine). Typically the bot management should know and play opening book for your engine. You may miss that function! Do that and you can save a lot of time and headaches!

If your bot management app can’t play opening book, try to find other ones. For example, you may try my chess GUI (BanksiaGUI). It can run your engine as a Lichess bot and of course it can play any opening book you choose for that bot.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
yodatk
Posts: 16
Joined: Mon Oct 26, 2020 2:49 pm
Full name: Tomer Gonen

Re: Openning Book for Chess Engine

Post by yodatk »

phhnguyen wrote: Thu Oct 29, 2020 7:31 am The solution is so simple: add an opening book to your bot management (but not your engine). Typically the bot management should know and play opening book for your engine. You may miss that function! Do that and you can save a lot of time and headaches!

If your bot management app can’t play opening book, try to find other ones. For example, you may try my chess GUI (BanksiaGUI). It can run your engine as a Lichess bot and of course it can play any opening book you choose for that bot.
Your Chess GUI can play as bot in lichess?? that is awsome! It took me a while to figure out the lichess-bot.py that lichess has released , I didn't know there is a simpler option. could have save me a lot of time I will definitely try it ! Thx!
:D