]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Faster handling of king captures in Position::see
[stockfish] / src / position.cpp
index 325f3e4db6b2ce023eadef0e575e0245237ec0f3..6f8747635772aa930a604025bd5b0c95a67dbbc2 100644 (file)
@@ -1077,20 +1077,23 @@ int Position::see(Move m) const {
 
       // Add the new entry to the swap list
       swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[MG][captured];
-      ++slIndex;
 
       // 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)
       {
-          swapList[slIndex++] = QueenValueMg * 16;
+          if (stmAttackers == attackers)
+              ++slIndex;
+
           break;
       }
 
+      stm = ~stm;
+      stmAttackers = attackers & pieces(stm);
+      ++slIndex;
+
   } while (stmAttackers);
 
   // Having built the swap list, we negamax through it to find the best