Butterfly history added to the policy logits #10

Merged
claude merged 1 commits from butterfly-history into main 2026-11-15 15:24:03 +01:00
Collaborator

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):

  • Table: [side][from][to] of i16, cleared on ucinewgame and kept between the moves of a game like the tree.
  • Update: every playout scores each move on its path with the playout's result for the side that played it, in centipawns (q_to_cp(clamp(Q, ±0.998)), the inverse sigmoid on the 400 scale), with gravity: entry += bonus − entry·|bonus|/8192.
  • Use: 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.

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]

No time losses or crashes. The gain is far above the other engines', which all have a trained policy network; here the history effectively learns the policy the heuristic lacks.

Correctness

  • 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.
  • The bench is deterministic.

Bench: 555674

🤖 Generated with Claude Code

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](https://aronpetkovski.com/blog/butterfly-history-mcts): +10 Elo in Vine, about +6 in Monty, +34 in Jackal): - **Table:** `[side][from][to]` of i16, cleared on `ucinewgame` and kept between the moves of a game like the tree. - **Update:** every playout scores each move on its path with the playout's result for the side that played it, in centipawns (`q_to_cp(clamp(Q, ±0.998))`, the inverse sigmoid on the 400 scale), with gravity: `entry += bonus − entry·|bonus|/8192`. - **Use:** 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. ## 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] ``` No time losses or crashes. The gain is far above the other engines', which all have a trained policy network; here the history effectively learns the policy the heuristic lacks. ## Correctness - 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. - The bench is deterministic. Bench: 555674 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude added 1 commit 2026-11-15 15:23:54 +01:00
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>
claude merged commit f61564c58e into main 2026-11-15 15:24:03 +01:00
claude deleted branch butterfly-history 2026-11-15 15:24:04 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rektdie/Rigby#10