From c1f9a359e8e319d832ee5a55277dab996dd29d25 Mon Sep 17 00:00:00 2001 From: bmc4 Date: Mon, 29 Nov 2021 14:51:35 -0300 Subject: [PATCH] Correctly reset bestMoveChanges for searches not using time management (e.g. analysis, fixed node game play etc), bestMoveChanges was not reset during search iterations. As LMR uses this quantity, search was somewhat weaker. Tested using fixed node playing games: ``` ./c-chess-cli -each nodes=10000 option.Hash=16 -engine cmd=../Stockfish/src/fix -engine cmd=../Stockfish/src/master -concurrency 6 -openings file=../books/UHO_XXL_+0.90_+1.19.epd -games 10000 Score of Stockfish Fix vs Stockfish Master: 3187 - 3028 - 3785 [0.508] 10000 ./c-chess-cli -each nodes=30000 option.Hash=16 -engine cmd=../Stockfish/src/fix -engine cmd=../Stockfish/src/master -concurrency 6 -openings file=../books/UHO_XXL_+0.90_+1.19.epd -games 10000 Score of Stockfish Fix vs Stockfish Master: 2946 - 2834 - 4220 [0.506] 10000 ``` closes https://github.com/official-stockfish/Stockfish/pull/3818 bench: 5061979 --- src/search.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 70dc4b21..c926c1d2 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -477,6 +477,13 @@ void Thread::search() { if (skill.enabled() && skill.time_to_pick(rootDepth)) skill.pick_best(multiPV); + // Use part of the gained time from a previous stable move for the current move + for (Thread* th : Threads) + { + totBestMoveChanges += th->bestMoveChanges; + th->bestMoveChanges = 0; + } + // Do we have time for the next iteration? Can we stop searching now? if ( Limits.use_time_management() && !Threads.stop @@ -489,13 +496,6 @@ void Thread::search() { // If the bestMove is stable over several iterations, reduce time accordingly timeReduction = lastBestMoveDepth + 9 < completedDepth ? 1.92 : 0.95; double reduction = (1.47 + mainThread->previousTimeReduction) / (2.32 * timeReduction); - - // Use part of the gained time from a previous stable move for the current move - for (Thread* th : Threads) - { - totBestMoveChanges += th->bestMoveChanges; - th->bestMoveChanges = 0; - } double bestMoveInstability = 1.073 + std::max(1.0, 2.25 - 9.9 / rootDepth) * totBestMoveChanges / Threads.size(); double totalTime = Time.optimum() * fallingEval * reduction * bestMoveInstability; -- 2.39.2