Skip to content

Fix non-canonical hash after null moves#1095

Merged
codedeliveryservice merged 1 commit into
codedeliveryservice:mainfrom
grepfuldead:fix/null-move-castling
Jul 7, 2026
Merged

Fix non-canonical hash after null moves#1095
codedeliveryservice merged 1 commit into
codedeliveryservice:mainfrom
grepfuldead:fix/null-move-castling

Conversation

@grepfuldead

Copy link
Copy Markdown
Contributor

increment_stack toggles the castling key out on every ply, which is the remove-old-rights half of the pair that make_move completes when it updates castling rights. make_null_move goes through increment_stack but never toggles it back, so the hash after a null move is left off by the castling term: a position reached via a null move hashes differently from the same position parsed from FEN.

Move the castling toggle out of the shared increment_stack into make_move, which owns both halves. Null moves now leave castling untouched, matching the standard convention (Stockfish, Viridithas).

STC
Elo | 3.45 +- 2.88 (95%)
SPRT | 8.0+0.08s Threads=1 Hash=16MB
LLR | 2.92 (-2.25, 2.89) [-2.75, 0.25]
Games | N: 14716 W: 3733 L: 3587 D: 7396
Penta | [43, 1679, 3779, 1803, 54]
https://recklesschess.space/test/15402/

LTC
Elo | 2.57 +- 2.47 (95%)
SPRT | 40.0+0.40s Threads=1 Hash=64MB
LLR | 2.91 (-2.25, 2.89) [-2.75, 0.25]
Games | N: 17832 W: 4442 L: 4310 D: 9080
Penta | [7, 2002, 4764, 2138, 5]
https://recklesschess.space/test/15403/

Bench: 2931707

increment_stack toggles the castling key out on every ply, which is the
remove-old-rights half of the pair that make_move completes when it
updates castling rights. make_null_move goes through increment_stack but
never toggles it back, so the hash after a null move is left off by the
castling term: a position reached via a null move hashes differently from
the same position parsed from FEN.

Move the castling toggle out of the shared increment_stack into make_move,
which owns both halves. Null moves now leave castling untouched, matching
the standard convention (Stockfish, Viridithas).

STC
Elo   | 3.45 +- 2.88 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=16MB
LLR   | 2.92 (-2.25, 2.89) [-2.75, 0.25]
Games | N: 14716 W: 3733 L: 3587 D: 7396
Penta | [43, 1679, 3779, 1803, 54]
https://recklesschess.space/test/15402/

LTC
Elo   | 2.57 +- 2.47 (95%)
SPRT  | 40.0+0.40s Threads=1 Hash=64MB
LLR   | 2.91 (-2.25, 2.89) [-2.75, 0.25]
Games | N: 17832 W: 4442 L: 4310 D: 9080
Penta | [7, 2002, 4764, 2138, 5]
https://recklesschess.space/test/15403/

Bench: 2931707
@codedeliveryservice codedeliveryservice merged commit 0be6cd4 into codedeliveryservice:main Jul 7, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants