From a66f31f1291a3778bf210ab3ef2b7720966655fb Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Thu, 10 Dec 2009 17:24:18 +0200 Subject: [PATCH] Synchronize pruning rules in search and sp_search Regression test passed: Mod - Orig: 365 - 351 Signed-off-by: Marco Costalba --- src/search.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index c1f90e11..0fe242dd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1814,6 +1814,7 @@ namespace { bool useFutilityPruning = sp->depth < SelectiveDepth && !isCheck; + const int FutilityMoveCountMargin = 3 + (1 << (3 * int(sp->depth) / 8)); const int FutilityValueMargin = 112 * bitScanReverse32(int(sp->depth) * int(sp->depth) / 2); while ( sp->bestValue < sp->beta @@ -1842,31 +1843,30 @@ namespace { && !captureOrPromotion) { // Move count based pruning - if ( moveCount >= 2 + int(sp->depth) + if ( moveCount >= FutilityMoveCountMargin && ok_to_prune(pos, move, ss[sp->ply].threatMove) && sp->bestValue > value_mated_in(PLY_MAX)) continue; // Value based pruning - if (sp->approximateEval < sp->beta) + if (sp->futilityValue == VALUE_NONE) { - if (sp->futilityValue == VALUE_NONE) - { - EvalInfo ei; - sp->futilityValue = evaluate(pos, ei, threadID) + FutilityValueMargin; - } + EvalInfo ei; + sp->futilityValue = evaluate(pos, ei, threadID) + FutilityValueMargin; + } - if (sp->futilityValue < sp->beta) + Value futilityValueScaled = sp->futilityValue - moveCount * IncrementalFutilityMargin; + + if (futilityValueScaled < sp->beta) + { + if (futilityValueScaled > sp->bestValue) // Less then 1% of cases { - if (sp->futilityValue > sp->bestValue) // Less then 1% of cases - { - lock_grab(&(sp->lock)); - if (sp->futilityValue > sp->bestValue) - sp->bestValue = sp->futilityValue; - lock_release(&(sp->lock)); - } - continue; + lock_grab(&(sp->lock)); + if (futilityValueScaled > sp->bestValue) + sp->bestValue = futilityValueScaled; + lock_release(&(sp->lock)); } + continue; } } -- 2.39.2