Analysis and engine

analyze — gammonNet catch-up

Writes a gammonNet analysis for every position that has none — the catch-up of a library built before this feature existed (ADR-0013, ADR-0015). It is the same operation as the automatic run after an import and the “Positions without analysis” line of the Maintenance tab of the graphical interface, and as the /v1/gammonnet.analyzeMissing endpoint of the serve daemon for a tenant — three different forms of the same operation, not three separate logics (see Headless mode (server)).

./blunderdb analyze --db <path> [options]

Options:

  • --db — Database (required).

  • --ply — Search depth (default: 2, the canonical setting).

  • --prune-k — Pruning width (default: 12, the canonical setting).

  • --candidates — Number of candidate moves kept per checker-play decision (default: 10).

  • --jobs — Number of positions analyzed in parallel (default: the number of cores of the machine). When fewer positions remain than cores (a short match, the end of the batch), each search spreads over the free cores; the result does not change by a single bit.

  • --match — Restrict the sweep to the positions of a single match (0, the default, means the whole library).

  • --compare — Writes nothing: compares gammonNet with the imported analyses instead of filling gaps (see below).

  • --stale — Re-analyzes the positions whose gammonNet analysis is stale — written by an earlier version of the engine, or at a depth other than --ply — instead of filling gaps. A position that also carries an XG, GNUbg or BGBlitz analysis is never touched.

  • --limit — With --compare, stops after this many positions (0 = all).

  • --format — Output format: text (default, with progress) or json (a single summary document, printed at the end).

  • --rollout — Rolls out the positions chosen by --query instead of filling gaps (see below).

  • --query — With --rollout, the positions to play, in the search query language (search --query-help); empty, all of them.

A match imported without an analysis thus gets a Performance Rating. That is the case of a match played online, or of a Jellyfish .mat file, that nobody ran through XG. blunderDB knew its positions and the moves played, but nothing said what they were worth; once the batch has run, the move actually played is compared with gammonNet’s ranking and the gap feeds the PR and every other indicator. The played move comes from the match’s own move table, written at import whether or not the file carried an analysis — it is never guessed.

A database analysed with a version older than this one does not need to be re-evaluated: repair recomputes the columns from what is already stored and gives those matches their PR back.

One match only (--match). With the id list --type matches prints, the sweep only walks the positions of that match: same gap rule, same guarantees, narrower scope. A match that has just been imported gets its analyses without the rest of the library being swept, and a match corrected then analysed a second time costs only the positions the correction created, since every other one already carries an analysis. The option combines with neither --stale nor --compare, which both look at positions that already have an analysis: asking for both is an error, rather than a silently ignored scope.

Parallelism (--jobs). The positions of a batch are independent — no search informs the next one — so they are spread over --jobs threads, each with its own evaluator. The analyses written are identical whatever the value of --jobs; only the computation time changes. --jobs 1 leaves the machine free for something else. Cancellation is not affected: Ctrl-C stops the batch before any new position, and everything already computed is written.

The hole rule (ADR-0013). A position that already carries an analysis — XG, GNUbg, BGBlitz, or a previous gammonNet run — is never touched, whichever engine is missing. Only a position with no analysis at all is written. The command can therefore be re-run at any time without risk, and interrupted cleanly: Ctrl-C cancels without losing anything already written, and the next run resumes exactly where the previous one stopped — no journal is needed, since “the positions without analysis” is recomputed on every launch.

Example:

./blunderdb analyze --db base.db

# Analyzing 1204 position(s) with gammonNet (2-ply, k=12, 16 job(s))...
#   1/1204 (0%)
#   61/1204 (5%)
#   ...
#   1204/1204 (100%)
# Done.

./blunderdb analyze --db base.db --jobs 1

# Un seul match, celui qui vient d'être importé
./blunderdb analyze --db base.db --match 12

Batch rollouts (--rollout). Each position chosen by --query is played by a rollout, one after the other on all cores, and the rollout is recorded beside its analysis, never in its place. The value is a preset — fast (216 games truncated at 7) or standard (1296 games truncated at 11) — or free settings: an optional preset, then games=, min-games=, truncation=, jsd=, ply=, candidates=, seed=, separated by commas. A position that already carries a rollout with the same settings is skipped: a run interrupted by Ctrl-C resumes where it stopped, the position in progress being dropped entirely. A position analysed only by a rollout is found by the search through it; a position already analysed keeps the columns of its analysis.

./blunderdb analyze --db base.db --rollout fast --query 'E>80'
./blunderdb analyze --db base.db --rollout 'standard,ply=1' --query 'c'

--compare: what is gammonNet worth on your library?

The engine’s accuracy is measured elsewhere against reference corpora and against the exact bear-off table. Neither of those measurements answers the question a user actually has, which is about their positions: on the matches imported from XG, where does the embedded engine disagree with the analysis that came in the file, and what would that disagreement cost?

--compare answers, and writes nothing. That is not a precaution but the point of the command: ADR-0013 protects an imported analysis unconditionally, so the comparison can be run on a library one particularly does not want rewritten.

The report gives:

  • the agreement rate on the best answer, split between checker plays and cube decisions — the two have nothing to do with each other and a single rate would hide which one is slipping;

  • the cost of the disagreement, priced on the imported analysis’s own scale: what the move gammonNet prefers is worth according to the imported engine, minus what its own best move is worth. That direction is the only one both engines can price together; pricing a disagreement twice would invite reading the smaller of the two numbers;

  • the breakdown by game phase, which is what says where the disagreements sit;

  • the ten most expensive disagreements, position by position.

Two engines write the same move differently — XG writes “13/7” where gammonNet writes “13/8 8/7”, hits are marked on one side and not the other, repetition is sometimes collapsed into “(2)”. Those differences are dialect, not disagreement: the comparison reduces both notations to a canonical form before comparing them. Without that, a test corpus showed 78.8 % agreement instead of 93.2 % — fifteen points of false disagreements.

A move the imported engine did not list cannot be priced on its scale: it counts as a disagreement of zero cost rather than of an invented one.

# Comparer sur un échantillon de 500 positions
./blunderdb analyze --db base.db --compare --limit 500

# compared: 118 decision(s)  (refused 2, failed 0)
# same best answer: 93.2% (110/118)
#   checker play:   93.7% (59/63)
#   cube decision:  92.7% (51/55)
# ...

rollout — Rollout of a position

Plays a position a large number of times with gammonNet, to settle what a search cannot: two moves a few thousandths apart, or a cube decision where the model hesitates. With dice, it is its moves that are played (the best ones at the rollout depth, at least 2 plies, or those named by --move); without dice, its cube decision (No double and Double/Take; Double/Pass is worth exactly +1). The position comes from an XGID or an OGID, or from a database (--db and --id); without --store, nothing is recorded.

./blunderdb rollout [options] '<XGID|OGID>'
./blunderdb rollout --db <path> --id <position> [--store] [options]

Options:

  • --preset — Starting setting: fast (default: 216 games truncated at 7 plies, stop at JSD 3 after 108) or standard (1296 games truncated at 11, stop at JSD 3 after 324). Both play at 0 ply — the network alone, for moves, cube and leaves; --ply 1 or more plays deeper, for a time several times longer. The following options override it one by one.

  • --games, --min-games, --truncation, --jsd, --ply, --candidates — The rollout parameters (--truncation 0 plays each game to the end, --jsd 0 never stops before the end).

  • --move — A move to play, in blunderDB notation (repeatable).

  • --seed — Dice seed, fixed by default: the same command gives the same numbers.

  • --jobs — Games played in parallel (default: one per core); only the running time changes.

  • --format — Output format: text or json (default: text).

  • --db, --id — The database and the identifier of the position to play, instead of an XGID.

  • --store — Records the finished rollout on the position, as a second analysis carrying its own settings, beside the imported or evaluated analysis, which it never replaces. An interrupted rollout is not recorded; of two rollouts with the same settings, the longer series is kept, and a rollout with other settings is added alongside.

  • --list — Prints the rollouts stored on the position, newest first, instead of rolling one out.

All candidates play the same dice, the luck of each roll is removed from the result of each game (variance reduction), the first two rolls are stratified, and a game stops where the two-sided bearoff database covers it. Each line gives the equity, its 95 % interval, the number of games played and the JSD, the gap to the best in standard deviations of the difference. The cube is played during the games: the ranking is more reliable than the absolute equity. Ctrl-C displays what the completed games have established.

Examples:

./blunderdb rollout 'XGID=-b----E-C---eE---c-e----B-:0:0:1:31:0:0:0:0:10'
./blunderdb rollout --move '8/5 6/5' --move '24/23 13/10' '<XGID>'
./blunderdb rollout --db base.db --id 42 --preset standard --store
./blunderdb rollout --db base.db --id 42 --list

epc — EPC calculator

Computes the Effective Pip Count, the winning probability and the money cube verdict of a bearoff position given as an XGID or an OGID (OpenGammon). Pure computation: no database file is involved.

./blunderdb epc [options] '<XGID|OGID>'

Options:

  • --format — Output format: text or json (default: text).

  • --bearoff-ts — Optional two-sided bearoff database (.bd) widening the built-in TS-06-06 (also read from the BLUNDERDB_TS_PATH environment variable). The widest valid database wins; an invalid file is ignored with a warning.

Regimes. Within the range the two-sided database covers, the winning probability and the money cube analysis (cubeless, ND, D/T, D/P, verdict) are exact. Outside it, the winning probability is estimated (convolution of the one-sided roll distributions plus a calibrated correction) and shown with its measured error margin; the cube verdict is deliberately never estimated (see ADR-0009).

Examples:

# Régime exact : six pions ou moins de chaque côté
./blunderdb epc 'XGID=-BBB------------------bbb-:0:0:1:00:0:0:0:0:10'

# Avec la table TS-06-11 calculée : exact jusqu'à onze pions par joueur
./blunderdb epc --bearoff-ts ~/.local/share/blunderdb/gnubg_ts6x11.bd 'XGID=…'

gnubgid — GNUbg ID

Writes the identifier GNU Backgammon shows for a position given as an XGID or an OGID: the position ID (the board, seen from the side of the player on roll) and the match ID (cube, score, dice), joined by a colon as GNU Backgammon copies them. Pure computation: no database file is involved. The match length and the scores are derived from the away scores the position holds, as the XGID does.

./blunderdb gnubgid [options] '<XGID|OGID>'

Options:

  • --format — Output format: text or json (default: text).

Examples:

./blunderdb gnubgid 'XGID=-b----E-C---eE---c-e----B-:0:0:1:00:0:0:0:0:10'
./blunderdb gnubgid --format json '<XGID>'

cubematrix — Cube matrix

Gives a position’s cube verdict at every score of a match: for each away × away cell, whether the position is a double and whether it is a take. Pure computation: no database is opened, the position arrives as an XGID or an OGID (OpenGammon).

./blunderdb cubematrix [options] '<XGID|OGID>'

Options:

  • --format — Output format: text or json (default: text).

  • --match-length — Match length the grid spans, from 1 to 25 (default: 7).

  • --ply — Search depth for every cell, 0 or 2 (default: 2).

  • --prune-k — Number of candidate moves kept by the prune network (default: 12).

  • --jobs — Searches run in parallel (default: one per core). The grid is identical whatever the value; only the time changes.

The position’s own score is ignored — the grid replaces it — but its cube is kept: the question asked is “at what score would I turn this cube”. The grid is post-Crawford throughout.

Every cell is its own search, because the engine is match-aware: a single search read through different match equities would be wrong exactly where the score matters.

Examples:

# Grille d'un match en 5 points
./blunderdb cubematrix --match-length 5 'XGID=-b----E-C---eE---c-e----B-:0:0:1:00:0:0:0:7:10'

# Les équités de chaque case, pour un script
./blunderdb cubematrix --format json '<XGID>'

text output: a grid whose rows are the points still needed by the player on roll and whose columns are the opponent’s, then the legend of the ND / DT / DP / TG tokens and the reason for each refused cell.

capture — Position from a screenshot

Reads the position shown by a screenshot of an eXtreme Gammon board (default theme): checkers, bar, borne-off checkers (what is missing from fifteen), dice, side to move and cube. The image (PNG, JPEG or GIF) can contain more than the board; larger than a 4K screen (3840×2160), it is shrunk before reading. The score is never read. What the reading cannot decide is listed as a doubt, never guessed: hidden arrow, stack taller than the five checkers XG draws side by side, unreadable dice.

./blunderdb capture [options] <image>

Options:

  • --format — Output format: text, json or xgid (default: text).

  • --db and --save — Saves the position in the database as an individual position.

  • --score — The score, which the capture does not show: money, or the two players’ Away scores, player 1’s (bottom) first, for example 2a/5a.

  • --turn — The side to move, 1 (bottom) or 2 (top), when no dice show it.

  • --force — Saves despite the reading’s doubts, once the board has been checked. It replaces neither --score nor --turn: --save refuses as long as the score, or the turn without dice, is not given, and names the missing option.

Examples:

./blunderdb capture capture.png
./blunderdb capture --format xgid capture.png
./blunderdb capture --db base.db --save --score 2a/5a capture.png
./blunderdb capture --db base.db --save --score money --turn 2 videau.png

The daemon offers the same reading: POST /v1/positions.fromImage with {"data": "<base64 image>"}. It refuses an image larger than a 4K screen instead of shrinking it, and reads only two images at a time.

bearoff — Bearoff databases

Makes and manages the bearoff databases. Nothing is downloaded and nothing is embedded: a table is computed here and checked against the fingerprint gnubg produces for its domain. No sub-command talks to a database — a bearoff table is arithmetic about the game, not about anyone’s positions — so none of them takes --db.

./blunderdb bearoff generate --ts <domain> [options]
./blunderdb bearoff list [options]
./blunderdb bearoff verify <file.bd> [options]
./blunderdb bearoff delete --ts <domain> [options]

The domain is written as under makebearoff: 6x9 for the two-sided table at nine chequers per player, os8 for the eight-point one-sided table (os alone means os6).

The two families do not answer the same question. A two-sided table widens the domain where the winning probability and the cube verdict are exact; a one-sided table widens how far from home a chequer may stand without the EPC going silent (up to ten points).

generate. States the size, the memory and the estimated time before starting, then shows the percentage and the measured remaining time.

  • --ts — Two-sided domain to compute, for example 6x9.

  • --os — One-sided domain to compute, as a point count: 6 to 12. Exactly one of the two is required.

  • --cores — Cores to use (default: every core but one).

  • --data-dir — Where to write it (default: the application’s data directory).

  • --quiet — No progress line.

CTRL-C pauses. The signal is caught: the state is written beside the table and the same command run again continues where it stopped rather than recomputing everything. Half an hour of arithmetic is worth writing down. bearoff delete throws a pending resume away. Only the two-sided sweep pauses; the one-sided one is sequential and --cores buys it nothing.

list. Prices every domain — size, memory, time on this machine — and says which are already present, with their verdict, and which have a paused run. --format json for a script, --cores to change the estimate’s assumption.

verify. Answers verified (the same bytes as the reference), unverified (well formed, but no fingerprint is recorded for that domain) or corrupt (the file contradicts itself). Exits with an error in the last case: this command is made to be put in a script.

delete. Removes the table, the pending resume and the debris of a dead run. A default domain is recomputed at the application’s next launch; a wider one is not.

Examples:

# Ce que cette machine a, et ce que chaque domaine coûterait
./blunderdb bearoff list

./blunderdb bearoff generate --ts 6x9 --cores 4

# OS-08 : l'EPC répond alors jusqu'à un pion sur la 8
./blunderdb bearoff generate --os 8

# Sur un serveur, dans le volume que lit le démon
./blunderdb bearoff generate --ts 6x11 --data-dir /srv/bearoff

./blunderdb bearoff verify /srv/bearoff/gnubg_ts6x11.bd

openingbook — Which move at this score?

The Opening exercise of the Training panel (see Training Panel) on the command line: the opening move (1st roll) or the reply (2nd roll) of a game at a score, drawn from the embedded opening book and judged against it. Every move tied with the best is right (see Opening book: gap, 95 % CI and tie). No database is read or written.

openingbook status — The number of rows in the book and its scores.

./blunderdb openingbook status [--book <fichier>] [--format text|json]

openingbook question — Draws a question: the opening roll and the score, with the XGID of the opening position; with --roll second, the reply roll in the position left by an opening move tied with the best at that score, with that move and the XGID of the reply position.

./blunderdb openingbook question [options]

Options:

  • --roll first|second — The roll to play: first (the opening, the default) or second (the reply).

  • --score <liste> — Scores to draw, separated by commas: 4-2 (the replier at 4 points, the opener at 2), 1-2 (Crawford game), 1-1 (the DMP, double match point), money.

  • --opening <liste>, --reply <liste> — Opening or reply rolls to draw (31,65); --reply only with --roll second.

  • --seed <n> — Reproducible draw (0 = random).

  • --book <fichier> — A .jsonl or .jsonl.gz book instead of the embedded one.

  • --format text|json — Output format.

openingbook answer — Judges a move and shows every candidate against the best: gap, 95 % CI and « tied », in score-normalised equity, with the number of games and the rollout setting. Without --after, the move is the opening; with --reply and --after, the move is the reply played after that opening move, the one named by the --roll second question.

./blunderdb openingbook answer --opening <jet> --score <score> [--reply <jet> --after <coup>] [options] '<coup>'

Examples:

./blunderdb openingbook question --score 4-2,2-4
./blunderdb openingbook answer --opening 31 --score 4-2 '8/5 6/5'
./blunderdb openingbook question --roll second --score 4-2
./blunderdb openingbook answer --opening 31 --reply 21 --score 4-2 --after '8/5 6/5' '13/11 6/5'