]> git.sesse.net Git - stockfish/commitdiff
Fix some silly bugs
authorJoona Kiiski <joona.kiiski@gmail.com>
Fri, 22 Jan 2010 20:54:28 +0000 (22:54 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 27 Jan 2010 09:14:20 +0000 (10:14 +0100)
SelectiveDepth was ignored

Test results for the whole futility pruning series:

4CPU:
Orig - Mod: 959 - 1027 (+12 elo)

1CPU:
Orig - Mod: 763 - 830 (+15 elo)

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

index f259ab707fe7983a271bdd6b05093490d6fe404a..6bc77d3ba61224197a72a5ada11e509ef08103c6 100644 (file)
@@ -1359,7 +1359,7 @@ namespace {
     Move ttMove, move;
     Depth ext, newDepth;
     Value bestValue, staticValue, nullValue, value, futilityValue, futilityValueScaled;
-    bool isCheck, useFutilityPruning, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
+    bool isCheck, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
     bool mateThreat = false;
     int moveCount = 0;
     futilityValue = staticValue = bestValue = value = -VALUE_INFINITE;
@@ -1430,7 +1430,7 @@ namespace {
     }
 
     // Post futility pruning
-    if (staticValue - PostFutilityValueMargin >= beta)
+    if (depth < SelectiveDepth && staticValue - PostFutilityValueMargin >= beta)
         return (staticValue - PostFutilityValueMargin);
 
     // Null move search
@@ -1510,7 +1510,6 @@ namespace {
     // to search all moves.
     MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
     CheckInfo ci(pos);
-    useFutilityPruning = depth < SelectiveDepth && !isCheck;
 
     // Loop through all legal moves until no moves remain or a beta cutoff occurs
     while (   bestValue < beta
@@ -1559,7 +1558,8 @@ namespace {
       // Futility pruning for captures
       Color them = opposite_color(pos.side_to_move());
 
-      if (    useFutilityPruning
+      if (   !isCheck
+          && newDepth < SelectiveDepth
           && !dangerous
           && pos.move_is_capture(move)
           && !pos.move_is_check(move, ci)
@@ -1579,7 +1579,7 @@ namespace {
 
 
       // Futility pruning
-      if (    useFutilityPruning
+      if (   !isCheck
           && !dangerous
           && !captureOrPromotion
           && !move_is_castle(move)
@@ -1599,19 +1599,22 @@ namespace {
           if (red >= 1.0)
               predictedDepth -= int(floor(red * int(OnePly)));
 
-          int preFutilityValueMargin = 0;
-          if (predictedDepth >= OnePly)
-              preFutilityValueMargin = 112 * bitScanReverse32(int(predictedDepth) * int(predictedDepth) / 2);
+          if (predictedDepth < SelectiveDepth)
+          {
+              int preFutilityValueMargin = 0;
+              if (predictedDepth >= OnePly)
+                  preFutilityValueMargin = 112 * bitScanReverse32(int(predictedDepth) * int(predictedDepth) / 2);
 
-          preFutilityValueMargin += MG.retrieve(pos.piece_on(move_from(move)), move_from(move), move_to(move)) + 45;
+              preFutilityValueMargin += MG.retrieve(pos.piece_on(move_from(move)), move_from(move), move_to(move)) + 45;
 
-          futilityValueScaled = ss[ply].eval + preFutilityValueMargin - moveCount * IncrementalFutilityMargin;
+              futilityValueScaled = ss[ply].eval + preFutilityValueMargin - moveCount * IncrementalFutilityMargin;
 
-          if (futilityValueScaled < beta)
-          {
-              if (futilityValueScaled > bestValue)
-                  bestValue = futilityValueScaled;
-              continue;
+              if (futilityValueScaled < beta)
+              {
+                  if (futilityValueScaled > bestValue)
+                      bestValue = futilityValueScaled;
+                  continue;
+              }
           }
       }