Introducing the Opening Book: four million positions from the first three rolls of backgammon
A free, open-source lookup table of four million GNUBG 3-ply evaluations covering the first three rolls and early cube decisions at every match score.
Import all your matches, analyze and explore any position, build a blunder database and study your mistakes. Try it today, it's completely free and no signup is required.
Today I am releasing the BackgammonDB Opening Book, free and open source. It is a lookup table of approximately 4.2 million precalculated positions covering the first three rolls and two cube decisions in Backgammon. Each position stores the top 8 candidate moves along with match equity and win/gammon/backgammon chances for each player.
Analysis was performed with GNUBG. At each position, every legal play was evaluated at what GNUBG calls 2-ply, and the top 8 then re-evaluated at 3-ply (note: XG, Snowie and other engines would call the depths 3-ply and 4-ply, respectively). Those top 8 are what the book stores — best-first, with full win/gammon/backgammon distributions and both cubeless and score-aware cubeful equities. Cube decisions are evaluated at 3-ply too.
If you want to start exploring it, check out The Opening Book page with an interactive explorer. You can review the code to generate the book and get the data on Github.
What's in the book
The book contains:
- The top 8 candidate moves for every opening roll in money games, and every possible match score up to 25-point matches.
- The top 8 candidate moves for every response roll to every possible opening roll, in money games and at every score of matches up to 15 points.
- The top 8 candidate moves from a pruned tree to the third roll, in money games and matches up to 9 points.
- It also calculates the correct cube action after the first and second roll (the latter in money games and matches up to 9 points). In the scenario of a good double-take, the book explores the position from a taken cube.
All match analysis includes Crawford and post-Crawford positions. Money games are explored both with and without Jacoby rule.
Tree pruning: To reduce the size of the tree, third moves only follow up to four good moves from the opening roll and response roll. Good moves are defined as ones where there is an equity loss of no more than 0.04. This also applies to good double-takes. So it will follow the best move, and the next three moves that are all considered non-errors; but bad moves from the first two rolls are discarded when exploring third-roll plays.
What actually is it?
The BackgammonDB Opening Book is actually three separate projects. All are free and, where relevant, open source.
- A ~1.5gb SQLite database, released under the Creative Commons Attribution license (CC BY 4.0), containing a lookup of every unique XGID in the book and the candidate move responses. This is available to download now and is free to use with attribution in personal and commercial projects.
- A Python project that (a) creates this opening book, (b) drives GNU Backgammon through its embedded Python API, exposing a clean JSON protocol, (c) provides a raft of code to check and cross-reference the opening book, and (d) provides a simple interface to look up positions in the database. You can use this code to extend the book into deeper positions or wider match scores.
- A web page, where you can play out the first 3 moves and see the results instantly from book lookup.
Why did you build this?
Something I really wanted with BackgammonDB was instant results as I explored positions. The Position Editor fires off requests the moment you create a position, but to keep things responsive (and the server not drowned in requests), these instant requests are necessarily 1-Ply (2-Ply in XG). That's useful for a quick glance, but deeper analysis is needed to properly understand positions.
As the opening is so often reviewed, it got me thinking if we could build an opening book - precalculate the first few rolls and get instant results. eXtreme Gammon has an opening book generated using XGR+ at 4-ply or 3-ply. But this book is much narrower in scope, containing around 50,000 positions for the opening and response rolls.
So I thought it would be fun to go a bit further.
This book should cover almost all opening and response rolls; the only misses will be responses in the early games (after the opening game) of very long matches. Third rolls are mostly covered up to 9-point matches when both players know their first two rolls: wacky opening or response players will result in a book miss for move 3.
Isn't this insanely repetitive? Surely the opening moves are basically the same at most match scores?
In a word: Yes. But you don't know unless you try! And while there was a lot of upfront compute cost, it is now very fast to check these things with any XGID and know you'll get the right answer (assuming you trust GNU's 3-ply analysis).
It also opens the possibility to do interesting things like explore exactly when it is correct to play, for example, an opening 64 as 8/2 6/2 over splitting or running, with a single SQL query and no trips to the engine.
Review your matches with BackgammonDB.
Import your backgammon matches, analyze positions, find your blunders, and quiz yourself on the positions you got wrong. Free, no account required.