]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Simplify Chess 960 castling
[stockfish] / src / position.cpp
index 954e5ffdf757637abed4591216004709b4c38c09..826e847f09e11a11835422764628341cf164f0ce 100644 (file)
@@ -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<ROOK>(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