Tree reuse keeps most of the previous tree, so the arena fills up fast. In a 240-move self-play diagnostic of main at 8+0.08 with Hash=64, the reused subtree alone was often 3.0-3.3M of the 3.35M nodes, and the tree was full on 90 moves (37%). A full tree cannot expand anything any more; for the rest of the move it only re-evaluates leaves. Now a failed allocation triggers a collection after the playout. The children of every node below a visit threshold are dropped (the node keeps its visits and Q and becomes a leaf again, expanded anew on its next visit), and the rest is packed in place with the same block compaction as tree reuse. The threshold is the smallest one that brings the tree down to half the arena; visits only shrink going down, so one pass over the tree gives the size kept for every threshold. In the same diagnostic with this change the tree was collected on 27 of 158 moves, once each, and search kept expanding afterwards; a collection of a full 64 MB tree costs about 20-30 ms. Checked: the -DRIGBY_VERIFY_TREE build verifies the tree after every collection; UCI-driven self-play passed 700 checks / 428 collections with 1 MB Hash and 476 checks / 205 collections with 16 MB, including repeated searches of the same position and a root at halfmove 99. uci, go wtime/nodes/infinite, stop and quit work. The bench is unchanged because the bench never fills the tree. Rebased from the earlier tree-gc branch onto main with the value network and second-visit expansion. Bench: 546018 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.1 KiB
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). - 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: move heuristics (captures, promotions, checks, pawn threats) until a policy network exists. - 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.
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 |
bench [playouts] |
Fixed playout search over the bench positions |
go depth N limits the mean playout depth. nodes in info lines are playouts.
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. |
| FPUReduction | 30 | First-play urgency reduction x100. |
| PolicyTemp | 100 | Policy softmax temperature x100. |
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.