# How do opening books in engine chess work?

I thought opening books were just big compilations of opening moves that engines have access to, and they choose at random which move to play from the list of moves that the opening book says is good. However if this is correct, I don't see how videos like this make sense. How can an opening book "beat" another?

Am I understanding opening books wrong? What are they exactly, and how do they make an engine stronger (if they actually make the engine stronger)?

Your understanding is more or less correct, an opening book is a large collection of positions and what are the "book moves" in that position. I don't know if engines typically choose at random if there are multiple moves in the book for a given position or if they do something more complicated, but that doesn't matter much for your question.

How can an opening book "beat" another?

It can contain better moves, and more of them, and they could even be better tailored to the specific opponent!

To figure out which is better, you let the same engine play against itself, with one side using one opening book and the other side the other. If you take care to have each book play white as often as black, you can see in the end which book had a higher score against the other book.

For instance, an opening book could contain a line somewhere that actually is not as good as the author thought at the time of putting it together, and the other book chooses to go for that position as the other side and it leads to a win for the engine.

Or one book is "done" after 15 moves after which the engine is on its own, but the other book still has several moves coming up after it on which the engine spent far more time on while creating the book than it could during the actual game.

Or the author of the opening book for engine A knows that engine B is worse at playing certain positions from the French, and he chooses to put moves into the book that causes A to go for those positions whenever it has the chance.

Or an opening book author spends days analyzing a certain position in an opening, and finally figures out that there is a way to force a good position for white there, and he adds it to the opening book. Engines with books that still allow that position to come up will have a bad time there.

And so on, opening books are in the end created by humans (with heavy use of engines) and the same arms race is going on there as between top human players.

• Does this mean that an opening book tailored for one engine might not work well for another (because different engines have different strengths and weaknesses)? Further, does this mean that if the opening book has a weakness (say, its understanding of the King's Indian isn't very good) that becomes an exploitable weakness? Commented Mar 4, 2019 at 18:56
• @Allure: in principle yes, but such differences between engines are usually very small and this is only a subject for experts. That might change now that a completely different type of engine exists (Alpha Zero / Leela Zero) that uses neural networks instead of alfa/beta search, in the TCEC final Stockfish vs Leela there were some openings where one engine clearly had the advantage over the other. Commented Mar 4, 2019 at 19:00
• Thanks for clarification. One more thing, does an engine using an opening book not have to think at all? That is, the main advantage of opening books is that they conserve time (since presumably if the engine is left to analyze itself it will also find the moves recommended by the opening book)? Commented Mar 4, 2019 at 19:03
• That's one advantage, but the moves it will find itself in five minutes won't be equal to the ones found by the collective work of the whole chess world over decades, of course. Commented Mar 4, 2019 at 19:05
• Do you know if opening books make engines deterministic? For example, the opening book dictate that the engine will always open with 1.e4? If not, how does it choose which move to make? Commented Mar 6, 2019 at 11:12

A better book gives better lines and moves for an engine. For example, if you were to construct a book based on beginner games (no more than 1200) on lichess, it would not perform well.

• Can you give more details? Like, what exactly does an opening book do for the engine? Commented Mar 4, 2019 at 8:56