From b19ad4977c0ee427eeff9c11bd7c4da9210cd090 Mon Sep 17 00:00:00 2001 From: xoto10 Date: Sun, 2 Dec 2018 15:29:31 +0000 Subject: [PATCH] Simplify time manager in search() Remove the F[] array which I find unhelpful and rename `improvingFactor` to `fallingEval` since larger values indicate a falling eval and more time use. I realise a test was not strictly necessary, but I ran STC [-3,1] just to check there are no foolish errors before creating the pull request: STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 35804 W: 7753 L: 7659 D: 20392 http://tests.stockfishchess.org/tests/view/5bef3a0c0ebc595e0ae39c19 It was then suggested to clean the constants around `fallingEval` to make it more clear this is a factor around ~1 that adjusts time up or downwards depending on some conditions. We then ran a double test with this simplification suggestion: STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 68435 W: 14936 L: 14906 D: 38593 http://tests.stockfishchess.org/tests/view/5c02c56b0ebc5902bcee0184 LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 37258 W: 6324 L: 6230 D: 24704 http://tests.stockfishchess.org/tests/view/5c030a520ebc5902bcee0a32 No functional change --- src/search.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index e63d72e8..6a63fcaa 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -492,10 +492,8 @@ void Thread::search() { && !Threads.stop && !Threads.stopOnPonderhit) { - const int F[] = { failedLow, - bestValue - mainThread->previousScore }; - - int improvingFactor = std::max(246, std::min(832, 306 + 119 * F[0] - 6 * F[1])); + double fallingEval = (306 + 119 * failedLow + 6 * (mainThread->previousScore - bestValue)) / 581.0; + fallingEval = std::max(0.5, std::min(1.5, fallingEval)); // If the bestMove is stable over several iterations, reduce time accordingly timeReduction = 1.0; @@ -509,7 +507,7 @@ void Thread::search() { // Stop the search if we have only one legal move, or if available time elapsed if ( rootMoves.size() == 1 - || Time.elapsed() > Time.optimum() * bestMoveInstability * improvingFactor / 581) + || Time.elapsed() > Time.optimum() * bestMoveInstability * fallingEval) { // If we are allowed to ponder do not stop the search now but // keep pondering until the GUI sends "ponderhit" or "stop". -- 2.39.2