Commit Graph
11 Commits
Author SHA1 Message Date
rektdieandclaude 6490286852 feat: coloured search output for a terminal
Started from a terminal, Rigby now shows its search for a human:
coloured progress lines (depth/seldepth, playouts, speed, time, a tree
fill bar, score in pawns, the PV fading with depth) at 125, 250, 500 ms
and then every second, and at the end a table of the most visited root
moves with a bar for their share of the visits, their score and prior.
Tree reuse and collections are shown as notes, and bestmove is
highlighted.

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 the coloured output. NO_COLOR turns it off. On Windows the
console gets ANSI processing and UTF-8 output.

Checked: the UCI output of a scripted session (two searches with tree
reuse, a stalemate root) is identical to main apart from nps and time;
go wtime, go infinite with stop, and quit work; the pretty mode was
driven in a real console, including the switch to UCI. Search is
untouched, so the bench is unchanged.

Bench: 546018

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:15:49 +01:00
claude 1754753a6e Merge pull request 'Collect the tree when the node arena is full' (#4) from tree-gc-nn into main
SPRT https://bench.rektdie.com/test/5286/
Elo   | 8.74 +- 6.47 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.00 (-2.94, 2.94) [0.00, 10.00]
Games | N: 3262 W: 996 L: 914 D: 1352
Penta | [48, 226, 1023, 264, 70]

Bench: 546018
2026-11-15 11:56:36 +01:00
rektdieandclaude 967e0e0b90 feat: collect the tree when the node arena is full
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>
2026-11-15 10:52:06 +01:00
claude 0d5713f7f0 Merge pull request 'Expand nodes on their second visit' (#3) from expand-second-visit-nn into main
SPRT https://bench.rektdie.com/test/5285/
Elo   | 31.92 +- 15.09 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 2.96 (-2.94, 2.94) [0.00, 10.00]
Games | N: 764 W: 260 L: 190 D: 314
Penta | [9, 56, 201, 88, 28]

Bench: 546018
2026-11-15 10:41:03 +01:00
rektdieandclaude cdeb318016 feat: expand nodes on their second visit
Most leaves are visited only once. Their first visit now only settles
terminal states and evaluates the position; the move list, the priors
and the child nodes are created when search comes back a second time.
The root is expanded before the first playout, so a search always has a
move.

With the value network the tree is full on nearly every move at
8+0.08 with Hash=64 (hashfull 1000 in a 30-ply self-play diagnostic);
with this change many moves stay at 320-890. The -DRIGBY_VERIFY_TREE
build passed 1700 tree checks in UCI-driven self-play with 1 MB and
16 MB Hash, and a 1-playout search still returns a move.

Rebased from the earlier expand-second-visit branch onto the network
main, without the tree collection it was built on.

Bench: 546018

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:21:06 +01:00
claude 6057476214 Merge pull request 'Value network trained on Lc0 data' (#2) from value-net into main
Merge pull request 'Value network trained on Lc0 data' (#2) from value-net into main

SPRT https://bench.rektdie.com/test/5284/
Elo   | 502.68 +- 147.15 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.05 (-2.94, 2.94) [0.00, 10.00]
Games | N: 162 W: 150 L: 5 D: 7

Bench: 545914
2026-11-15 04:18:12 +01:00
rektdieandclaude 30b0c36cd5 feat: value network trained on Lc0 data
The static evaluation behind the quiescence search is now a
(768 -> 128)x2 -> 1 SCReLU network instead of the hand-written
evaluation. It was trained with bullet on linrock's Lc0-derived test80
2024-02 binpack, 40 superbatches (10 min on an RTX 3070), final loss
0.0220. The quiescence search itself is unchanged.

The network is embedded with incbin (EVALFILE, default
networks/rigby-value-v1.bin). Q is tanh(cp / 800), the same scale the
network was trained on (sigmoid(cp / 400) = expected score).

Checked: bullet's float evaluation of fixed positions (trainer --check)
and the engine's quantised inference (evalfens) agree within 6 cp; an
integer re-implementation in Python matches the engine exactly. Perft
passes, bench is deterministic.

Bench: 545914

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:12:52 +01:00
rektdieandclaude 530c4d67ed train: value network trainer on Lc0 data
A bullet trainer for a (768 -> 128)x2 -> 1 SCReLU value network, reading
linrock's Lc0-derived Stockfish binpacks directly (no conversion). The
target blends the game result (0.4) with the search score; 40
superbatches by default, about 12 minutes on an RTX 3070.

train/value/train.ps1 sets up CUDA 13.3 and cargo, unpacks the default
binpack if needed, builds and runs. train/README.md documents the data,
the setup and the network file layout for the engine side.

No engine change.

Bench: 546127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 03:57:51 +01:00
claude 241ad4a546 Merge pull request 'Reuse the search tree between moves' (#1) from tree-reuse into main
Merge pull request 'Reuse the search tree between moves' (#1) from tree-reuse into main

SPRT https://bench.rektdie.com/test/5282/
Elo   | 162.54 +- 22.80 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.13 (-2.94, 2.94) [0.00, 5.00]
Games | N: 472 W: 238 L: 32 D: 202

Bench: 546127
2026-11-15 03:15:32 +01:00
rektdieandclaude 5c017ee43f feat: reuse the search tree between moves
When the new position continues the previous game, find its node in the
old tree (matching the keys of the positions played since) and make it
the root. Its subtree is packed to the front of the arena in place: child
blocks are always allocated after their parent's, so moving the kept
blocks in their original order only moves them towards the front.

A root that was a draw inside the old tree (repetition, 50 moves) or was
never expanded starts afresh. ucinewgame and Hash changes drop the tree.

Built with -DRIGBY_VERIFY_TREE, the engine checks every tree before and
after reuse (legal moves, visit counts); 2900+ such checks over self-play
games, with 16 MB and 1 MB hash, found no inconsistency.

Bench: 546127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 01:23:42 +01:00
rektdieandclaude d3044c0b88 feat: minimal MCTS engine with UCI
Bitboard board with fancy magics and fully legal move generation, checked
by a perft suite. PUCT search over a node arena with FPU reduction and
in-tree draw detection. Hand-written value (eval + quiescence) and
heuristic policy stand in until the network is trained. UCI loop with a
search thread, OpenBench-compatible bench and Makefile.

Bench: 546127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:31:20 +01:00