From a55fb76dcc66c9cc17a81a9a99dd506108ee1fee Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 3 Jul 2013 18:58:49 +0200 Subject: [PATCH] Simplify aspiration window code Here the main difference is that now we center aspiration window on last returned score. This allows to simplify handling of mate scores. We have done a reversed SPRT tests, where we wanted to verify if master is stronger than this patch. Long TC: master vs this patch (reverse test) LLR: -2.95 (-2.94,2.94) Total: 37992 W: 7012 L: 6920 D: 24060 bench: 4507288 --- src/search.cpp | 55 +++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index e1b7a1d7..15a9cde5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -296,9 +296,12 @@ namespace { Value bestValue, alpha, beta, delta; memset(ss-1, 0, 4 * sizeof(Stack)); - depth = BestMoveChanges = 0; - bestValue = delta = -VALUE_INFINITE; (ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains + + depth = BestMoveChanges = 0; + bestValue = delta = alpha = -VALUE_INFINITE; + beta = VALUE_INFINITE; + TT.new_search(); History.clear(); Gains.clear(); @@ -328,17 +331,12 @@ namespace { // MultiPV loop. We perform a full root search for each PV line for (PVIdx = 0; PVIdx < PVSize; PVIdx++) { - // Set aspiration window default width - if (depth >= 5 && abs(RootMoves[PVIdx].prevScore) < VALUE_KNOWN_WIN) + // Reset aspiration window starting size + if (depth >= 5) { delta = Value(16); - alpha = RootMoves[PVIdx].prevScore - delta; - beta = RootMoves[PVIdx].prevScore + delta; - } - else - { - alpha = -VALUE_INFINITE; - beta = VALUE_INFINITE; + alpha = std::max(RootMoves[PVIdx].prevScore - delta,-VALUE_INFINITE); + beta = std::min(RootMoves[PVIdx].prevScore + delta, VALUE_INFINITE); } // Start with a small aspiration window and, in case of fail high/low, @@ -366,35 +364,28 @@ namespace { if (Signals.stop) return; - // In case of failing high/low increase aspiration window and + // In case of failing low/high increase aspiration window and // research, otherwise exit the loop. - if (bestValue > alpha && bestValue < beta) - break; - - // Give some update (without cluttering the UI) before to research - if (Time::now() - SearchTime > 3000) - sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; - - if (abs(bestValue) >= VALUE_KNOWN_WIN) + if (bestValue <= alpha) { - alpha = -VALUE_INFINITE; - beta = VALUE_INFINITE; + alpha = std::max(bestValue - delta, -VALUE_INFINITE); + + Signals.failedLowAtRoot = true; + Signals.stopOnPonderhit = false; } else if (bestValue >= beta) - { - beta += delta; - delta += delta / 2; - } + beta = std::min(bestValue + delta, VALUE_INFINITE); + else - { - Signals.failedLowAtRoot = true; - Signals.stopOnPonderhit = false; + break; - alpha -= delta; - delta += delta / 2; - } + delta += delta / 2; assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE); + + // Give some update (without cluttering the UI) before to research + if (Time::now() - SearchTime > 3000) + sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; } // Sort the PV lines searched so far and update the GUI -- 2.39.2