]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Simplify King Evasion
[stockfish] / src / position.cpp
index 6c5a11b2595dad24ccbdcaa27f615cd749d424fb..ec356ace9b01494ae6a81801fda383d191b81cdd 100644 (file)
@@ -544,7 +544,7 @@ bool Position::legal(Move m) const {
   // If the moving piece is a king, check whether the destination square is
   // attacked by the opponent.
   if (type_of(piece_on(from)) == KING)
-      return !(attackers_to(to) & pieces(~us));
+      return !(attackers_to(to, pieces() ^ from) & pieces(~us));
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.