X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=71a101041404fe00b0c0ded394755632dc937158;hp=c894403cc452337c87abfc2d3cd99227b892a645;hb=548bae80bd1f04526667ddeeaf8f5f065c53b096;hpb=2360c8aa2fb852a7999b9716406e650423f5e4a4 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.