]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Cleanup and optimize Position::has_mate_threat()
[stockfish] / src / search.cpp
index 2ab983970dcceb8f8466db7398b875ef9962709c..652893282ca35bc51767bcee3d535aa2328ff10f 100644 (file)
@@ -715,6 +715,7 @@ namespace {
     alpha = *alphaPtr;
     beta = *betaPtr;
     isCheck = pos.is_check();
+    depth = (Iteration - 2) * OnePly + InitialDepth;
 
     // Step 1. Initialize node (polling is omitted at root)
     ss->currentMove = ss->bestMove = MOVE_NONE;
@@ -764,7 +765,6 @@ namespace {
             captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
             // Step 11. Decide the new search depth
-            depth = (Iteration - 2) * OnePly + InitialDepth;
             ext = extension<PV>(pos, move, captureOrPromotion, moveIsCheck, false, false, &dangerous);
             newDepth = depth + ext;
 
@@ -1168,7 +1168,7 @@ namespace {
 
     // Expensive mate threat detection (only for PV nodes)
     if (PvNode)
-        mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move()));
+        mateThreat = pos.has_mate_threat();
 
     // Initialize a MovePicker object for the current position
     MovePicker mp = MovePicker(pos, ttMove, depth, H, ss, (PvNode ? -VALUE_INFINITE : beta));
@@ -2035,7 +2035,7 @@ namespace {
     if (   m != MOVE_NULL
         && before != VALUE_NONE
         && after != VALUE_NONE
-        && pos.captured_piece() == NO_PIECE_TYPE
+        && pos.captured_piece_type() == PIECE_TYPE_NONE
         && !move_is_special(m))
         H.set_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
   }