]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Faster handling of king captures in Position::see
[stockfish] / src / position.cpp
index 8f38493027b07e9f8c273ae95d73f046ea8026b3..6f8747635772aa930a604025bd5b0c95a67dbbc2 100644 (file)
@@ -1080,13 +1080,18 @@ int Position::see(Move m) const {
 
       // Locate and remove the next least valuable attacker
       captured = min_attacker<PAWN>(byTypeBB, to, stmAttackers, occupied, attackers);
-      stm = ~stm;
-      stmAttackers = attackers & pieces(stm);
 
       // Stop before processing a king capture
-      if (captured == KING && stmAttackers)
+      if (captured == KING)
+      {
+          if (stmAttackers == attackers)
+              ++slIndex;
+
           break;
+      }
 
+      stm = ~stm;
+      stmAttackers = attackers & pieces(stm);
       ++slIndex;
 
   } while (stmAttackers);