]> git.sesse.net Git - stockfish/commitdiff
Don't update bestValue when pruning
authorMarco Costalba <mcostalba@gmail.com>
Thu, 8 Dec 2011 18:12:17 +0000 (19:12 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 10 Dec 2011 16:35:36 +0000 (17:35 +0100)
Simply return a fail-low score

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp
src/thread.cpp

index 5d753e8ea7be3281332731b0617ecde637c266ee..4c69a0522f90310e2eeb4fcf1d70197cab8954a9 100644 (file)
@@ -948,6 +948,9 @@ split_point_start: // At split points actual search starts from here
     {
         lock_grab(&(sp->lock));
         bestValue = sp->bestValue;
+        moveCount = sp->moveCount;
+
+        assert(bestValue > -VALUE_INFINITE && moveCount > 0);
     }
 
     // Step 11. Loop through moves
@@ -1065,13 +1068,7 @@ split_point_start: // At split points actual search starts from here
           if (futilityValue < beta)
           {
               if (SpNode)
-              {
                   lock_grab(&(sp->lock));
-                  if (futilityValue > sp->bestValue)
-                      sp->bestValue = bestValue = futilityValue;
-              }
-              else if (futilityValue > bestValue)
-                  bestValue = futilityValue;
 
               continue;
           }
@@ -1220,9 +1217,17 @@ split_point_start: // At split points actual search starts from here
     // case of StopRequest or thread.cutoff_occurred() are set, but this is
     // harmless because return value is discarded anyhow in the parent nodes.
     // If we are in a singular extension search then return a fail low score.
-    if (!SpNode && !moveCount)
+    if (!moveCount)
         return excludedMove ? oldAlpha : inCheck ? value_mated_in(ss->ply) : VALUE_DRAW;
 
+    // We have pruned all the moves, so return a fail-low score
+    if (bestValue == -VALUE_INFINITE)
+    {
+        assert(!playedMoveCount);
+
+        bestValue = alpha;
+    }
+
     // Step 21. Update tables
     // If the search is not aborted, update the transposition table,
     // history counters, and killer moves.
index cf35c28857305b68c7b17ff768836b51d27956c1..9c132a03abf3250532593ac7b818ba325d1be524 100644 (file)
@@ -263,7 +263,7 @@ Value ThreadsManager::split(Position& pos, Stack* ss, Value alpha, Value beta,
                             Value bestValue, Depth depth, Move threatMove,
                             int moveCount, MovePicker* mp, int nodeType) {
   assert(pos.pos_is_ok());
-  assert(bestValue >= -VALUE_INFINITE);
+  assert(bestValue > -VALUE_INFINITE);
   assert(bestValue <= alpha);
   assert(alpha < beta);
   assert(beta <= VALUE_INFINITE);