Commit Graph
40 Commits
Author SHA1 Message Date
rektdieandclaude 15258f952a feat: policy network inference
src/policy.cpp runs the network train/policy writes: 3072 threat
inputs (side to move's view, flipped horizontally when its king is on
files e-h, +768 attacked, +1536 defended), a hidden layer with CReLU
and pairwise product, and one output row per move, i8 weights scaled
by 128. The hidden width is read from the file's size, so any trained
width loads. When a network is loaded, eval::policy uses its logits
plus the butterfly-history bias instead of the move heuristics; the
temperature and softmax are unchanged.

A network is built in with make POLICYFILE=<net> (default: none, so
the engine plays as before) or loaded at runtime with the UCI option
PolicyFile. policyfens prints the priors of the trainer's --check
positions.

Checked: with a smoke-trained network policyfens matches the trainer's
float output to a few tenths of a percent in all six positions (black
to move, mirrored king, castling, promotion). Speed with a network:
-13% nps at 512 hidden, -41% at 2048. A zero network built in with
POLICYFILE gives uniform priors. Without a network the bench is
unchanged.

Bench: 529903

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:27:38 +01:00
rektdieandclaude 1c9d2beec3 feat: policy network trainer on Lc0 visit distributions
train/policy is a fork of montytrain's policy trainer (the one Monty,
Vine and Jackal use: bullet at a pinned revision plus two CUDA
operations, SelectAffine over the legal moves' output rows and a
softmax cross-entropy against the visit distribution). Rigby's
version drops Monty's SEE split of the outputs (3920 rows, as in
Vine), takes its arguments on the command line and checks a
checkpoint with --check.

The Stockfish binpacks used for the value net only keep the played
move, so the data comes from Lc0's raw V6 training tars instead.
lc02monty rebuilds each game from its first record and the played
moves and checks every record: pieces must match, and the moves Lc0
gave a probability must be exactly the legal moves. Lc0 writes
castling as king-takes-rook; Chess960 games keep their rook files.
On a test91 tar all 351,454 records convert. fetch.ps1 downloads a
run's hourly tars day by day, converts and deletes them, and
interleave shuffles the day files into one.

Defaults sized for a 20-minute run on the RTX 3070: 1024 hidden,
10 superbatches of 100M positions (~1M positions/s). The pinned
cudarc does not know CUDA 13.3, so env.ps1 sets
CUDARC_CUDA_VERSION=13000.

Checked: a smoke run on one tar lowers the loss from 2.89 to 2.38 and
gives plausible opening priors; a checkpoint reloads to identical
output; interleaved data trains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:27:08 +01:00
rektdieandclaude 9643c7b0a5 feat: Chess960 support
Castling works with any rook placement: each castling right remembers
its rook square (Position::castle_rook), set from KQkq (X-FEN, the
outermost rook on that side of the king) or Shredder-FEN file letters.
Castling moves stay king-from to king-destination (g/c file), so move
indices, history tables and the bench are unchanged; make_move lifts
king and rook before placing them, since in 960 their squares can
overlap. Rights are dropped by a king move or a move from or to a
castling rook's square. Generation follows the 960 rules: every square
the king or rook crosses or lands on is empty apart from the two, and
no square the king crosses or lands on is attacked with the moving rook
out of the occupancy (the king's own square included when it does not
move: the rook leaving can uncover the rank). has_legal_move falls back
to full generation for non-standard castling setups.

UCI_Chess960 writes and reads castling as the king taking its rook;
FEN output uses KQkq for outermost rooks and file letters otherwise.
New command perftfile <epd> [depth] runs an EPD perft file.

Checked: the 960 positions of the standard Chess960 perft suite
(fischer.epd) all match to depth 5 (17.6 billion nodes), perftsuite 6
passes, has_legal_move agrees with full generation at every perft node
to depth 4 of the 960 suite, castling both ways over UCI in 960 mode.
Lc0's training data has about 4% Chess960 games, which the policy data
converter now keeps.

Bench: 529903

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:26:45 +01:00
claude 1dacc9c402 Merge pull request 'Separate, higher cpuct at the root' (#17) from root-cpuct into main
SPRT https://bench.rektdie.com/test/5298/
Elo   | 12.06 +- 8.95 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.01 (-2.94, 2.94) [0.00, 10.00]
Games | N: 3344 W: 1251 L: 1135 D: 958
Penta | [133, 328, 682, 348, 181]

Bench: 529903
2026-11-15 16:45:49 +01:00
rektdieandclaude b89ab39bdd feat: separate, higher cpuct at the root
The root is where the move is chosen, so it pays to keep more of its
moves in play than deeper in the tree. Monty uses root_cpuct 0.4119
against cpuct 0.2826, a ratio of 1.458; with Rigby's cpuct of 1.6 that
gives a root cpuct of 2.33. The visit scaling applies on top as before.
Exposed as the UCI option RootCPuct (x100) next to CPuct for later
tuning.

Note on the previous commit: Monty's current cpuct_visits_scale is
37.63 (x128 = 4817), not 64; Rigby keeps 8192.

Bench is deterministic. setoption RootCPuct works.

Bench: 529903

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:20:25 +01:00
claude d39b8a3a4a Merge pull request 'cpuct grows with the parent's visits' (#16) from cpuct-scaling into main
SPRT https://bench.rektdie.com/test/5297/
Elo   | 38.82 +- 18.01 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.00 (-2.94, 2.94) [0.00, 10.00]
Games | N: 746 W: 294 L: 211 D: 241
Penta | [16, 63, 160, 90, 44]

Bench: 536817
2026-11-15 16:18:43 +01:00
rektdieandclaude 75c500ba61 feat: cpuct grows with the parent's visits
The exploration constant was fixed at 1.6. With tree reuse the root and
the nodes near it reach hundreds of thousands of visits, where a fixed
cpuct leaves the other children almost no chance. Now, as in Monty,
cpuct is multiplied by 1 + ln((N + 8192) / 8192) for a node with N
visits (Monty's default scale, 64 x 128; the factor is independent of
the Q range). Nodes under a few thousand visits are nearly unchanged;
at 10k visits cpuct is x1.8, at 1M x5.8.

Checked: the best move is the same as main's in four positions at 200k
playouts (Qxf7# included). The log costs up to about 10% speed in fast
endgame playouts.

Bench: 536817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:11:51 +01:00
claude d8b1d6ef6f Merge pull request 'Hard time limit for moves still open at the soft limit' (#15) from soft-hard-limit into main
SPRT https://bench.rektdie.com/test/5296/
Elo   | 30.48 +- 15.36 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.25 (-2.94, 2.94) [0.00, 10.00]
Games | N: 1120 W: 439 L: 341 D: 340
Penta | [40, 88, 229, 140, 63]

Bench: 554375
2026-11-15 16:10:02 +01:00
rektdieandclaude bf62fe185f feat: hard time limit for moves still open at the soft limit
With smart pruning most searches stop early and the clock piles up:
after move 40 of 8+0.08 self-play about 5 s of the 8 s were left. A
diagnostic of 202 searches showed 190 settled early; the 12 that reached
the time limit were the open ones (the best move had a median 50% of the
root visits, and was the best by Q in only 3 of 12).

So reaching the soft limit (the old allocation) is itself the sign of an
open move. Under a game clock such a search now runs on, with smart
pruning measured against a hard limit of min(3 x soft, remaining / 3),
until it settles or reaches that limit. movetime, nodes and infinite are
unchanged (their hard limit is the soft one).

Self-play diagnostic at 8+0.08 (3 games, 80 plies), main -> this:
average time per move 152-156 -> 162-189 ms, longest move about 350 ->
860-1040 ms, clock left after move 40 4.8-5.4 -> 2.4-5.0 s. go movetime
500 still stops at 480 ms; a 300 ms clock uses 6 ms.

The bench is unchanged: it searches by playout count.

Bench: 554375

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:01:27 +01:00
claude ca921ce2e2 Merge pull request 'Smart pruning stops clock searches whose best move is settled' (#14) from smart-pruning into main
SPRT https://bench.rektdie.com/test/5295/
Elo   | 24.75 +- 13.56 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.24 (-2.94, 2.94) [0.00, 10.00]
Games | N: 1364 W: 501 L: 404 D: 459
Penta | [39, 133, 273, 166, 71]

Bench: 554375
2026-11-15 15:57:37 +01:00
rektdieandclaude 6da27e2fad feat: smart pruning stops clock searches whose best move is settled
Under a game clock a search now stops early when no other root move can
catch up with the leading one in the playouts the remaining time still
allows (at the speed so far, divided by Lc0's smart-pruning factor
1.33). The saved time goes to later moves, whose allocation is a share
of the remaining clock. movetime, nodes and infinite searches are not
affected.

Only the visits gained in this search count, and the move leading them
must also be the most visited overall. Counting the reused tree's visits
stopped almost every search at once: the reused best move often has
hundreds of thousands of visits no rival could reach (a first version
spent 39 ms per move instead of 230 in self-play at 8+0.08).

Self-play diagnostic at 8+0.08 (3 games, 80 plies), main -> this:
average time per move 230 -> 157 ms, clock left after move 40
2.0 s -> 4.6-5.2 s.

The bench is unchanged: it searches by playout count.

Bench: 554375

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:47:04 +01:00
claude 6f4c3b2656 Merge pull request 'Escape bonus for any piece the opponent can win' (#13) from policy-escape-see into main
SPRT https://bench.rektdie.com/test/5294/
Elo   | 103.71 +- 29.38 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.20 (-2.94, 2.94) [0.00, 10.00]
Games | N: 338 W: 174 L: 76 D: 88
Penta | [5, 15, 60, 55, 34]

Bench: 554375
2026-11-15 15:41:40 +01:00
rektdieandclaude 246af156ef feat: escape bonus for any piece the opponent can win
The policy rewarded moving a piece away (0.003 x its value) only when an
enemy pawn attacked it. A knight attacked by an undefended-against bishop
got nothing. Now the bonus goes to every move of a knight, bishop, rook
or queen standing where the opponent wins it in an exchange: their least
valuable attacker starts it and SEE (from their side) gains at least 1;
a king may only take an undefended piece. A pawn attack always passes
this test, so the old case is covered. The result is computed once per
square in each policy call.

The counterpart of the quiet-move SEE penalty on the target square.

Example: with a white knight on e5 attacked by Bd6 and undefended, its
four retreats rank first (5.6-6.1%); in the Ruy Lopez the defended Nc6
gets no bonus.

Bench is deterministic.

Bench: 554375

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:36:46 +01:00
claude 2ac8d64ca9 Merge pull request 'SEE penalty for quiet moves that hang the piece' (#12) from policy-quiet-see into main
SPRT https://bench.rektdie.com/test/5293/
Elo   | 247.64 +- 50.37 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.96 (-2.94, 2.94) [0.00, 10.00]
Games | N: 258 W: 190 L: 32 D: 36
Penta | [1, 4, 30, 24, 70]

Bench: 549158
2026-11-15 15:34:36 +01:00
rektdieandclaude da1b0e61e1 feat: SEE penalty for quiet moves that hang the piece
The policy only penalised a quiet move when an enemy pawn attacked the
target square. A knight stepping in front of a bishop or a pawn pushed
into an undefended capture got no penalty. Now any quiet move whose
static exchange on the target square loses material (SEE < 0) loses
0.004 x the moving piece's value from its logit, the same penalty the
pawn threat gave. Every move to a pawn-attacked square fails this SEE,
so the old case is covered; the pawn-threat penalty stays for captures
only, as before.

Example (Italian, white to move): b4 (hangs to Bf8) and g4 (to Nf6) drop
from about 3.4% to 2.4%, Bd5 (Nxd5 exd5 loses the exchange of a bishop
for a knight) to 1.0%; castling and developing moves stay on top.

Bench is deterministic.

Bench: 549158

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:30:29 +01:00
claude 4f3c0ba2b3 Merge pull request 'SEE decides the capture bonus in the policy' (#11) from policy-see into main
SPRT https://bench.rektdie.com/test/5292/
Elo   | 222.16 +- 49.14 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.59 (-2.94, 2.94) [0.00, 10.00]
Games | N: 248 W: 178 L: 38 D: 32
Penta | [2, 4, 32, 24, 62]

Bench: 552832
2026-11-15 15:28:50 +01:00
rektdieandclaude 1460f5e81e feat: SEE decides the capture bonus in the policy
The +262 Elo of butterfly history showed that the hand-written policy
is the main weakness. One clear flaw: every capture got a +1 logit
bonus, including ones that just lose the piece (a knight taking a
defended pawn, a bishop sacrifice on f7). Now a capture whose static
exchange on the square loses material (SEE < 0) gets -1 instead of +1;
the victim and attacker terms are unchanged.

Example priors (startpos-like middlegame, white to move): Nxe5 with the
pawn defended 0.3%, Bxf7+ 1.4%, while winning captures stay on top
(Nxe5 against an undefended pawn 10.8%).

Bench is deterministic.

Bench: 552832

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:25:53 +01:00
claude f61564c58e Merge pull request 'Butterfly history added to the policy logits' (#10) from butterfly-history into main
SPRT https://bench.rektdie.com/test/5291/
Elo   | 261.71 +- 54.35 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.93 (-2.94, 2.94) [0.00, 10.00]
Games | N: 248 W: 195 L: 37 D: 16
Penta | [0, 3, 35, 11, 75]

Bench: 555674
2026-11-15 15:24:01 +01:00
rektdieandclaude 0f1657eb00 feat: butterfly history added to the policy logits
Rigby's policy is a hand-written heuristic, so it often ranks moves
badly in ways the search itself finds out. Following Vine's butterfly
history for MCTS (aronpetkovski.com/blog/butterfly-history-mcts: +10
Elo in Vine, about +6 in Monty, +34 in Jackal):

- a [side][from][to] table of i16, cleared on ucinewgame and kept
  between the moves of a game like the tree;
- every playout scores each move on its path with the playout's result
  for the side that played it, converted to centipawns
  (q_to_cp(clamp(Q, +-0.998)), i.e. the inverse sigmoid on the 400
  scale), with gravity: entry += bonus - entry * |bonus| / 8192;
- on expansion, entry / 16384 is added to each move's policy logit
  before the softmax. The priors are a snapshot; later updates do not
  change them.

Constants are Vine's, no tuning.

Checked: after 50k playouts the root moves' entries make sense (Qxf7#
at +8192, queen-losing moves at -5000 to -7800). The
-DRIGBY_VERIFY_TREE build passed 477 tree checks with 297 collections
at 1 MB Hash. Bench is deterministic.

Bench: 555674

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:20:42 +01:00
claude 786783d7d1 Merge pull request 'Incremental NNUE accumulator in quiescence' (#9) from nnue-incremental into main
SPRT https://bench.rektdie.com/test/5290/ (non-regression)
Elo   | 27.50 +- 10.61 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.07 (-2.94, 2.94) [-5.00, 0.00]
Games | N: 1608 W: 575 L: 448 D: 585
Penta | [28, 107, 443, 162, 64]

Bench: 546966
2026-11-15 15:18:27 +01:00
rektdieandclaude 8ceee77166 perf: incremental NNUE accumulator in quiescence
Every quiescence node built the network's hidden layer from the whole
board: about 30 pieces x 2 perspectives x 128 weights, a third of a
middlegame playout. The accumulator (both perspectives) is now built
once at the root of the quiescence search and passed down; each child
gets a copy updated with the two to four features the move changes
(normal move, capture, en passant, promotion, castling). i16 sums wrap
the same way in any order, so the values, and the search, are exactly
the same as before.

Playouts per second at 100k playouts, main -> this (two runs each):

  startpos           688k -> 705k   +2%
  QGD middlegame     453k -> 495k   +9%
  Kiwipete           128k -> 161k   +26%
  Sicilian middle    385k -> 440k   +14%
  rook endgame       881k -> 905k   +3%
  bench              3.87M -> 4.39M +14%

Checked: on 3,240,535 moves from random games (276,756 captures, 3,676
castles, 433 en passant, 30,900 promotions) the updated accumulator is
byte for byte equal to a fresh one, and a whole game played on updates
alone does not drift. The bench is identical to main.

Bench: 546966

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:03:40 +01:00
claude 807ddd90c1 Merge pull request 'Generate only captures in quiescence' (#8) from qs-captures-gen into main
SPRT https://bench.rektdie.com/test/5289/ (non-regression)
Elo   | 66.75 +- 16.38 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 3.07 (-2.94, 2.94) [-5.00, 0.00]
Games | N: 764 W: 311 L: 166 D: 287
Penta | [6, 46, 172, 113, 45]

Bench: 546966
2026-11-15 15:00:51 +01:00
rektdieandclaude 695d2dd30d perf: generate only captures in quiescence
Out of check the quiescence search only searches captures and queen
promotions, but every node generated all legal moves and threw the
quiet ones away. It now generates just those (generate_noisy: the same
legal generator with captures-only targets, no quiet pawn pushes, no
castling), in the same order as the full generation, so search is
unchanged. A node without any noisy move still has to tell stalemate
from a quiet position; has_legal_move answers that and stops at the
first legal move it finds.

Playouts per second at 100k playouts, main -> this (two runs each):

  startpos           631k -> 725k   +15%
  QGD middlegame     390k -> 446k   +14%
  Kiwipete           106k -> 142k   +34%
  Sicilian middle    334k -> 423k   +27%
  rook endgame       851k -> 982k   +15%

Checked: perftsuite 7 passes. On 252,893 positions from random games
(captures preferred, so they reach endgames, promotions and 400
positions without legal moves) generate_noisy equals generate_legal
filtered to captures and queen promotions, in the same order, and
has_legal_move equals a non-empty generate_legal. The bench is
identical to main.

Bench: 546966

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:52:58 +01:00
claude c45450255a Merge pull request 'SEE pruning of losing captures in quiescence' (#7) from qs-see into main
SPRT https://bench.rektdie.com/test/5288/
Elo   | 115.97 +- 32.64 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=64MB
LLR   | 2.98 (-2.94, 2.94) [0.00, 10.00]
Games | N: 292 W: 146 L: 52 D: 94
Penta | [4, 11, 52, 45, 34]

Bench: 546966
2026-11-15 14:50:06 +01:00
rektdieandclaude ed1c2b77f7 feat: SEE pruning of losing captures in quiescence
Profiling showed that 80-85% of a middlegame playout is the quiescence
search behind the value network: 15-41 quiescence nodes per leaf, since
every capture was searched, including ones that just lose the piece.

The quiescence search now skips captures whose static exchange on the
target square loses material (SEE < 0) when not in check. The SEE is the
usual threshold swap (least valuable attacker first, x-rays opened as
pieces leave, a king recaptures only an undefended square, pins
ignored); castling, en passant and promotions count as even.

Effect at 60k playouts (instrumented build, qsearch nodes per leaf and
time per playout):

  startpos           3.7 -> 2.2     -20%
  QGD middlegame    14.7 -> 4.2     -54%
  Kiwipete          41.4 -> 25.5    -25%
  Sicilian middle   21.0 -> 3.4     -68%
  rook endgame       2.6 -> 2.3      -2%

Checked: the SEE matches an independent python-chess reference exactly
on 9957 captures from 3000 random positions (4884 with recaptures).
Bench is deterministic. Move generation is untouched.

Bench: 546966

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:43:40 +01:00
claude 8f69f4f6f1 Merge pull request 'Live framed search dashboard for a terminal' (#6) from pretty-dashboard into main
Display only, no SPRT: output before the first "uci" command changes,
search and the UCI output do not.

Bench: 546018
2026-11-15 14:34:51 +01:00
rektdieandclaude 4973535596 refactor: drop the board and piece glyphs from the dashboard
The dashboard keeps the statistics, the principal variation and the
root moves; the board and the knight glyph in the titles are gone. The
statistics take the full width, with the evaluation and time bars
capped at about half of it.

Checked: node-limited UCI output is still identical to main, bench
unchanged.

Bench: 546018

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:33:45 +01:00
rektdieandclaude c859163e2c feat: live framed search dashboard for a terminal
The terminal output is now a framed dashboard that is redrawn in place
ten times a second instead of a growing list of lines:

- the root position as a coloured board, with the best move's squares
  highlighted;
- the score, white's expected score as an evaluation bar, depth, playouts,
  speed, time with a progress bar (time or playout limit), tree fill and
  notes on tree reuse and collections;
- the principal variation in SAN with move numbers, wrapped and fading
  with depth;
- the most visited root moves (SAN) with a bar for their share of the
  visits, score and prior;
- a spinner while searching, "done" at the end, and bestmove in SAN.

Each frame moves the cursor back to the top of the previous one and
clears below it; lines the user typed under the dashboard (e.g. stop)
are counted and drawn over. The box adapts to the terminal's width and
height (fewer root moves, then no blank lines, the board only when it
fits). RIGBY_PRETTY=1 forces the dashboard into a pipe.

Checked: UCI output is unchanged (node-limited searches identical to
main, including tree reuse and a stalemate root; time-limited ones
differ only in node counts); go wtime, go infinite + stop and quit
work; the dashboard was driven in a real console, including the redraw,
a reused tree and the switch to UCI, and its colours were checked
rendered to HTML. Search is untouched, so the bench is unchanged.

Bench: 546018

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:30:47 +01:00
claude 31a35fd84f Merge pull request 'Coloured search output for a terminal' (#5) from pretty-print into main
Display only, no SPRT: output before the first "uci" command changes,
search and the UCI output do not.

Bench: 546018
2026-11-15 14:17:01 +01:00
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