]> git.sesse.net Git - stockfish/commitdiff
Implement calculate_reduction function
authorJoona Kiiski <joona.kiiski@gmail.com>
Wed, 27 Jan 2010 20:56:11 +0000 (22:56 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 28 Jan 2010 10:14:43 +0000 (11:14 +0100)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index c894403cc452337c87abfc2d3cd99227b892a645..71a101041404fe00b0c0ded394755632dc937158 100644 (file)
@@ -286,6 +286,7 @@ namespace {
   bool ok_to_prune(const Position& pos, Move m, Move threat);
   bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply);
   Value refine_eval(const TTEntry* tte, Value defaultEval, int ply);
+  Depth calculate_reduction(double baseReduction, int moveCount, Depth depth, double reductionInhibitor);
   void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount);
   void update_killers(Move m, SearchStack& ss);
   void update_gains(const Position& pos, Move move, Value before, Value after);
@@ -2679,6 +2680,20 @@ namespace {
       return defaultEval;
   }
 
+  // calculate_reduction() returns reduction in plies based on
+  // moveCount and depth. Reduction is always at least one ply.
+
+  Depth calculate_reduction(double baseReduction, int moveCount, Depth depth, double reductionInhibitor) {
+
+    double red = baseReduction + ln(moveCount) * ln(depth / 2) / reductionInhibitor;
+
+    if (red >= 1.0)
+        return Depth(int(floor(red * int(OnePly))));
+    else
+        return Depth(0);
+
+  }
+
   // update_history() registers a good move that produced a beta-cutoff
   // in history and marks as failures all the other moves of that ply.