]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Fix critical SEE bug (take 2)
[stockfish] / src / position.cpp
index 8ea3f00a7881abee5bc80bd472da882359f0fc64..cecdcbf8a0e2e59029a7890011e9ecbd683c952a 100644 (file)
@@ -1195,6 +1195,12 @@ int Position::see(Move m, int asymmThreshold) const {
   do {
       assert(slIndex < 32);
 
   do {
       assert(slIndex < 32);
 
+      if (captured == KING) // Stop before processing a king capture
+      {
+          swapList[slIndex++] = QueenValueMg * 16;
+          break;
+      }
+
       // Add the new entry to the swap list
       swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[MG][captured];
       slIndex++;
       // Add the new entry to the swap list
       swapList[slIndex] = -swapList[slIndex - 1] + PieceValue[MG][captured];
       slIndex++;
@@ -1205,15 +1211,6 @@ int Position::see(Move m, int asymmThreshold) const {
       stm = ~stm;
       stmAttackers = attackers & pieces(stm);
 
       stm = ~stm;
       stmAttackers = attackers & pieces(stm);
 
-      if (captured == KING)
-      {
-          // Stop before processing a king capture
-          if (stmAttackers)
-              swapList[slIndex++] = QueenValueMg * 16;
-
-          break;
-      }
-
   } while (stmAttackers);
 
   // If we are doing asymmetric SEE evaluation and the same side does the first
   } while (stmAttackers);
 
   // If we are doing asymmetric SEE evaluation and the same side does the first