From dd9609521437dc839236c36d35bdb8cb633ba19f Mon Sep 17 00:00:00 2001 From: bmc4 Date: Sun, 17 Jan 2021 15:21:45 -0300 Subject: [PATCH] Simplify Chess 960 castling a little cleanup, and small speedup (about 0.3%) for Chess 960. Verified with perft on a large set of chess960 positions. Closes https://github.com/official-stockfish/Stockfish/pull/3317 No functional change --- src/position.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 954e5ffd..826e847f 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -533,11 +533,9 @@ bool Position::legal(Move m) const { if (attackers_to(s) & pieces(~us)) return false; - // In case of Chess960, verify that when moving the castling rook we do - // not discover some hidden checker. + // In case of Chess960, verify if the Rook blocks some checks // For instance an enemy queen in SQ_A1 when castling rook is in SQ_B1. - return !chess960 - || !(attacks_bb(to, pieces() ^ to_sq(m)) & pieces(~us, ROOK, QUEEN)); + return !chess960 || !(blockers_for_king(us) & to_sq(m)); } // If the moving piece is a king, check whether the destination square is -- 2.39.2