From 548bae80bd1f04526667ddeeaf8f5f065c53b096 Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Wed, 27 Jan 2010 22:56:11 +0200 Subject: [PATCH] Implement calculate_reduction function Signed-off-by: Marco Costalba --- src/search.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/search.cpp b/src/search.cpp index c894403c..71a10104 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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. -- 2.39.2