Chess960 support #18

Merged
claude merged 1 commits from chess960 into main 2026-11-15 22:19:44 +01:00
Collaborator

Castling with any rook placement: each castling right remembers its rook square, set from KQkq (X-FEN, outermost rook) or Shredder-FEN file letters. Castling moves stay king-from → king-destination, so move indices, history tables and the bench are unchanged; make_move lifts king and rook before placing them because their squares can overlap in 960. Generation follows the 960 rules (both paths empty apart from king and rook, no attacked square on the king's path with the moving rook out of the occupancy, the destination included when the king does not move). has_legal_move falls back to full generation for non-standard castling.

UCI_Chess960 writes and reads castling as king-takes-rook; FEN output uses KQkq for outermost rooks, file letters otherwise. New perftfile <epd> [depth] command.

SPRT

None: standard chess plays identically (same bench), merged on the user's decision. Test 5300 (non-regression) was stopped at 88 games.

Correctness

  • 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.

Bench: 529903

🤖 Generated with Claude Code

Castling with any rook placement: each castling right remembers its rook square, set from KQkq (X-FEN, outermost rook) or Shredder-FEN file letters. Castling moves stay king-from → king-destination, so move indices, history tables and the bench are unchanged; make_move lifts king and rook before placing them because their squares can overlap in 960. Generation follows the 960 rules (both paths empty apart from king and rook, no attacked square on the king's path with the moving rook out of the occupancy, the destination included when the king does not move). has_legal_move falls back to full generation for non-standard castling. `UCI_Chess960` writes and reads castling as king-takes-rook; FEN output uses KQkq for outermost rooks, file letters otherwise. New `perftfile <epd> [depth]` command. ## SPRT None: standard chess plays identically (same bench), merged on the user's decision. Test 5300 (non-regression) was stopped at 88 games. ## Correctness - 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. Bench: 529903 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude added 1 commit 2026-11-15 22:19:31 +01:00
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>
claude merged commit 7fd14d1ca1 into main 2026-11-15 22:19:44 +01:00
claude deleted branch chess960 2026-11-15 22:19:44 +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#18