Add Chess960 (FRC) and DFRC support

- castling moves are stored as "king takes own rook" (from = king square, to = castling rook square)
- per-colour castling rook squares (Board::castleRook), so DFRC (different back ranks for white/black) works
- FEN parsing/printing: KQkq (X-FEN) and Shredder-FEN file letters
- Board::CanCastle(): generic castling legality (empty paths, king not attacked, rook x-ray check)
- MakeMove handles arbitrary king/rook start squares (king and rook may stay in place or swap through each other's squares)
- UCI_Chess960 option: castling printed/parsed as king-takes-rook when on, standard e1g1 style otherwise (both are accepted when parsing)
- viri format, perft castle check and castling right updates no longer assume a1/h1/a8/h8
This commit is contained in:
claude committed 2026-10-11 00:12:02 +02:00
1 parent e984510434
commit aa97abaadc
9 files changed
+247 -71

No files matched your search

+4 -1
View File
@@ -3,7 +3,10 @@
#include <array>
#include <string_view>
using U64 = uint64_t;
using U64 = uint64_t;
// UCI_Chess960 option: castling moves are printed/parsed as "king takes own rook" when enabled
inline bool UCIChess960 = false;
constexpr std::string_view StartingFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
constexpr std::string_view KiwiPeteFen = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -";