]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Remove useless variable 'PostFutilityValueMargin'
[stockfish] / src / search.cpp
index e205db6fa163d56b5dfccc5efbb8692b6c22a8cf..7b9b5b370b5aac62a916e6dcb3d020dbaa065e10 100644 (file)
@@ -185,6 +185,8 @@ namespace {
   // and near frontier nodes.
   const Value FutilityMarginQS = Value(0x80);
 
+  Value FutilityMargins[2 * PLY_MAX_PLUS_2]; // Initialized at startup.
+
   // Each move futility margin is decreased
   const Value IncrementalFutilityMargin = Value(0x8);
 
@@ -576,6 +578,14 @@ void init_threads() {
   for (i = 0; i < THREAD_MAX; i++)
       Threads[i].activeSplitPoints = 0;
 
+  // Init futility margins array
+  FutilityMargins[0] = FutilityMargins[1] = Value(0);
+
+  for (i = 2; i < 2 * PLY_MAX_PLUS_2; i++)
+  {
+      FutilityMargins[i] = Value(112 * bitScanReverse32(i * i / 2)); // FIXME: test using log instead of BSR
+  }
+
   // Initialize global locks
   lock_init(&MPLock, NULL);
   lock_init(&IOLock, NULL);
@@ -1458,7 +1468,6 @@ namespace {
 
     // Calculate depth dependant futility pruning parameters
     const int FutilityMoveCountMargin = 3 + (1 << (3 * int(depth) / 8));
-    const int PostFutilityValueMargin = 112 * bitScanReverse32(int(depth) * int(depth) / 2);
 
     // Evaluate the position statically
     if (!isCheck)
@@ -1472,7 +1481,7 @@ namespace {
         }
 
         ss[ply].eval = staticValue;
-        futilityValue = staticValue + PostFutilityValueMargin; //FIXME: Remove me, only for split
+        futilityValue = staticValue + FutilityMargins[int(depth)]; //FIXME: Remove me, only for split
         staticValue = refine_eval(tte, staticValue, ply); // Enhance accuracy with TT value if possible
         update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
     }
@@ -1483,8 +1492,8 @@ namespace {
     // FIXME: test with modified condition 'depth < RazorDepth'
     if (  !isCheck
         && depth < SelectiveDepth
-        && staticValue - PostFutilityValueMargin >= beta)
-        return staticValue - PostFutilityValueMargin;
+        && staticValue - FutilityMargins[int(depth)] >= beta)
+        return staticValue - FutilityMargins[int(depth)];
 
     // Null move search
     if (    allowNullmove
@@ -1626,7 +1635,7 @@ namespace {
           int preFutilityValueMargin = 0;
 
           if (newDepth >= OnePly)
-              preFutilityValueMargin = 112 * bitScanReverse32(int(newDepth) * int(newDepth) / 2);
+              preFutilityValueMargin = FutilityMargins[int(newDepth)];
 
           Value futilityCaptureValue = ss[ply].eval + pos.endgame_value_of_piece_on(move_to(move)) + preFutilityValueMargin + ei.futilityMargin + 90;
 
@@ -1663,7 +1672,7 @@ namespace {
           {
               int preFutilityValueMargin = 0;
               if (predictedDepth >= OnePly)
-                  preFutilityValueMargin = 112 * bitScanReverse32(int(predictedDepth) * int(predictedDepth) / 2);
+                  preFutilityValueMargin = FutilityMargins[int(predictedDepth)];
 
               preFutilityValueMargin += H.gain(pos.piece_on(move_from(move)), move_from(move), move_to(move)) + 45;