]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Don't need to check for bestValue < beta to split
[stockfish] / src / search.cpp
index 52e7600b073e2e2617c894dfdae1d71a94f3e8f1..654efb3265f453caf9e8cfe398e04c625abc0b08 100644 (file)
@@ -1003,9 +1003,10 @@ split_point_start: // At split points actual search starts from here
       // Step 19. Check for splitting the search
       if (   !SpNode
           &&  depth >= Threads.min_split_depth()
-          &&  bestValue < beta
           &&  Threads.available_slave_exists(thisThread))
       {
+          assert(bestValue < beta);
+
           bestValue = Threads.split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove,
                                                depth, threatMove, moveCount, mp, NT);
           if (bestValue >= beta)
@@ -1090,7 +1091,7 @@ split_point_start: // At split points actual search starts from here
     Key posKey;
     Move ttMove, move, bestMove;
     Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
-    bool givesCheck, enoughMaterial, evasionPrunable;
+    bool givesCheck, enoughMaterial, evasionPrunable, fromNull;
     Depth ttDepth;
 
     // To flag BOUND_EXACT a node with eval above alpha and no available moves
@@ -1099,6 +1100,7 @@ split_point_start: // At split points actual search starts from here
 
     ss->currentMove = bestMove = MOVE_NONE;
     ss->ply = (ss-1)->ply + 1;
+    fromNull = (ss-1)->currentMove == MOVE_NULL;
 
     // Check for an instant draw or maximum ply reached
     if (pos.is_draw<false, false>() || ss->ply > MAX_PLY)
@@ -1136,7 +1138,14 @@ split_point_start: // At split points actual search starts from here
     }
     else
     {
-        ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
+        if (fromNull)
+        {
+            // Approximated score. Real one is slightly higher due to tempo
+            ss->staticEval = bestValue = -(ss-1)->staticEval;
+            ss->evalMargin = VALUE_ZERO;
+        }
+        else
+            ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
 
         // Stand pat. Return immediately if static value is at least beta
         if (bestValue >= beta)
@@ -1171,6 +1180,7 @@ split_point_start: // At split points actual search starts from here
       // Futility pruning
       if (   !PvNode
           && !InCheck
+          && !fromNull
           && !givesCheck
           &&  move != ttMove
           &&  enoughMaterial