]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Clean razoring code (step 6)
[stockfish] / src / search.cpp
index 56f89456373fc5d6043d8d12fa4d431810aa1d37..dbb23b8b067fea0e44e4a1188b4db7c905ae5608 100644 (file)
@@ -158,7 +158,12 @@ namespace {
   };
 
 
   };
 
 
-  /// Constants
+  /// Adjustments
+
+  // Step 6. Razoring
+
+  const Depth RazorDepth = 4 * OnePly;
+  inline Value razor_margin(Depth d) { return Value(0x200 + 0x10 * d); }
 
   // Search depth at iteration 1
   const Depth InitialDepth = OnePly;
 
   // Search depth at iteration 1
   const Depth InitialDepth = OnePly;
@@ -184,9 +189,6 @@ namespace {
   // remaining ones we will extend it.
   const Value SingleReplyMargin = Value(0x20);
 
   // remaining ones we will extend it.
   const Value SingleReplyMargin = Value(0x20);
 
-  // Depth limit for razoring
-  const Depth RazorDepth = 4 * OnePly;
-
   /// Lookup tables initialized at startup
 
   // Reduction lookup tables and their getter functions
   /// Lookup tables initialized at startup
 
   // Reduction lookup tables and their getter functions
@@ -1332,15 +1334,15 @@ namespace {
     if (   !value_is_mate(beta)
         && !isCheck
         && depth < RazorDepth
     if (   !value_is_mate(beta)
         && !isCheck
         && depth < RazorDepth
-        && refinedValue < beta - (0x200 + 16 * depth)
+        && refinedValue < beta - razor_margin(depth)
         && ss[ply - 1].currentMove != MOVE_NULL
         && ttMove == MOVE_NONE
         && !pos.has_pawn_on_7th(pos.side_to_move()))
     {
         && ss[ply - 1].currentMove != MOVE_NULL
         && ttMove == MOVE_NONE
         && !pos.has_pawn_on_7th(pos.side_to_move()))
     {
-        Value rbeta = beta - (0x200 + 16 * depth);
+        Value rbeta = beta - razor_margin(depth);
         Value v = qsearch(pos, ss, rbeta-1, rbeta, Depth(0), ply, threadID);
         if (v < rbeta)
         Value v = qsearch(pos, ss, rbeta-1, rbeta, Depth(0), ply, threadID);
         if (v < rbeta)
-          return v; //FIXME: Logically should be: return (v + 0x200 + 16 * depth);
+          return v; //FIXME: Logically should be: return (v + razor_margin(depth));
     }
 
     // Step 7. Static null move pruning
     }
 
     // Step 7. Static null move pruning