Bench: 764208
One node per position, found through a key table, as in docs/mcgs-plan.md
sections 3.1-3.5 and 3.6.5:
- Key table: open addressing with linear probing over 8-byte slots
{key_hi, node}, a power of two of at least twice the node arena. A hit
needs the full 64-bit key and the node's 16-bit check (about 80 bits).
It is rebuilt from the survivors after every collection and reroot.
- create_node: a position's first visit creates and evaluates its node
(checkmate, stalemate, insufficient material except at the root, then
ValueHash, then the net) with N = base = 1, q = u. The root is created
and evaluated through it.
- Descent: after make_move, repetition and the 50-move rule (mate first)
are judged before the lookup and recorded only as the edge's draw count.
An edge is linked on first selection, to an existing node when the
table has one. MAX_PLAYOUT_DEPTH = 512 guards against key collisions.
- Backprop: each path edge counts the visit (and the draw), each path
node recomputes q = (base*u - sum (N-D)*c.q) / N, summed in double.
ValueHash is stored for every path node; butterfly history as before.
A playout whose node allocation fails is dropped and the graph collected.
- Selection, best move, smart pruning, score, PV and dashboard read edges,
with path draws counted as 0. The PV stops after a repeated position.
- The root's edges are checked against its legal moves at search start;
the graph is cleared otherwise.
- GC threshold: visited bitmap and the root counted apart, so the estimate
stays an upper bound on a DAG.
- Hash: node arena, edge arena (8 edges per node, unchanged) and the
table share the graph's budget; the table's power of two is rounded
down or up, whichever leaves more nodes.
- VERIFY: verify_tree checks the graph per plan 3.8 (keys, table, states
from the position alone, edges, N = base + edge visits, q = u on
leaves); check (b) of `verify` identifies nodes by key.
The bench changes (663779 -> 764208) because the tree becomes a graph:
transpositions share nodes, so playouts run through existing nodes and
their depths and the positions they visit change; the root gets its own
evaluation and N = 1 + the edges' visits; and repetitions and the 50-move
rule are judged on every playout instead of once per node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rigby
Rigby is a UCI chess engine built on Monte Carlo Tree Search (PUCT). The goal is a neural-network-guided MCTS engine, later a Monte Carlo Graph Search (MCGS), with a value and policy network trained with bullet on data generated by Leela Chess Zero, and CUDA inference.
Every change is validated with SPRT on OpenBench.
Current state (0.1-dev)
- Bitboard board with fancy magic attacks, fully legal move generation, copy-make.
Verified with a perft suite (
Rigby perftsuite). - Chess960: any castling rook placement, X-FEN and Shredder-FEN castling rights,
UCI_Chess960for king-takes-rook castling notation. Verified with the 960 positions of the standard Chess960 perft suite to depth 5 (perftfile). - PUCT search: node arena with contiguous children, first-play urgency reduction, two-fold repetition, 50-move and insufficient-material draws inside the tree.
- Value: a
(768 -> 128)x2 -> 1network trained with bullet on Lc0 data (networks/rigby-value-v1.bin, embedded at build time; seetrain/README.md), behind a capture-only quiescence search. - Policy: a
3072 -> 1024 -> 3920network trained on Lc0 visit distributions (networks/rigby-policy-v1.bin, embedded at build time; seetrain/README.md). Built without one (POLICYFILE=), move heuristics (captures, promotions, checks, pawn threats). - Tree reuse between moves: the subtree of the new position is packed to the front of the node arena in place, so it costs no extra memory.
- When the arena is full, the least visited parts of the tree are cut back to leaves (keeping their visits and Q) and the rest is packed, so search never stops expanding.
- Single-threaded.
Building
Needs clang++ (C++20) and make. On Windows clang must have a MinGW runtime,
the build targets x86_64-w64-windows-gnu, same as Eleanor.
make
make EXE=Rigby-dev
make EVALFILE=path/to/quantised.bin
EVALFILE defaults to networks/rigby-value-v1.bin. POLICYFILE defaults to
networks/rigby-policy-v1.bin; POLICYFILE= builds the move heuristics instead.
Compiling with -DRIGBY_VERIFY_TREE checks the whole tree before and after every
reuse and after every collection (legal moves, visit counts) and aborts on the first
inconsistency. It is slow, for debugging only.
UCI
Standard commands: uci, isready, ucinewgame, position, go
(wtime btime winc binc movestogo movetime nodes depth infinite), stop, quit,
setoption.
Extra commands:
| Command | Meaning |
|---|---|
d |
Print the board, FEN and hash key |
eval |
Static (network) and quiescence evaluation of the current position |
evalfens |
Network evaluation of fixed positions, to compare with the trainer's --check |
perft <depth> |
Perft with per-move breakdown |
perftsuite [maxdepth] |
Standard perft positions with expected counts |
perftfile <epd> [maxdepth] |
Perft of every <fen> ;D1 <n> ;D2 <n> ... line of a file (e.g. a Chess960 suite) |
policyfens |
Policy network priors of fixed positions, to compare with the trainer's --check |
bench [playouts] |
Fixed playout search over the bench positions |
go depth N limits the mean playout depth. nodes in info lines are playouts.
Started from a terminal, Rigby shows its search for a human instead: a framed
dashboard, redrawn in place ten times a second, with the score and an evaluation
bar, depth, playouts, speed, a time bar, tree fill, the principal variation in SAN
and the most visited root moves with their share of the visits, score and prior.
It adapts to the terminal's size. The
first uci command switches to plain UCI output for good; GUIs and match runners
send it first and read stdout through a pipe, so they never see it. NO_COLOR
turns it off, RIGBY_PRETTY=1 forces it into a pipe (e.g. less -R). It needs a
terminal with 24-bit colour and UTF-8 (Windows Terminal, any modern Linux/macOS
terminal).
Options
| Option | Default | Meaning |
|---|---|---|
| Hash | 64 | Tree memory in MB. A node takes 20 bytes. |
| Threads | 1 | Only 1 for now. |
| MoveOverhead | 20 | Milliseconds kept back per move. |
| CPuct | 160 | Exploration constant x100. |
| RootCPuct | 233 | Exploration constant at the root x100. |
| FPUReduction | 30 | First-play urgency reduction x100. |
| PolicyTemp | 100 | Policy softmax temperature x100. |
| UCI_Chess960 | false | Write and read castling as the king taking its rook (e1h1). |
| PolicyFile | <empty> |
Policy network file to use instead of the built-in one. |
Bench
Rigby bench runs 5000 playouts on each of 16 positions. The reported node count is
the number of positions visited in the tree over all playouts, so it changes
whenever search behaviour changes, while the playout count stays fixed.