From 04a320666efce725ef66d1a84aaef493a880153d Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 23 Oct 2020 07:39:35 +0200 Subject: [PATCH] Change handling the special case of a single legal move. Using no searching time in case of a single legal move is not beneficial from a strength point of view, and this special case can be easily removed: STC: LLR: 2.93 (-2.94,2.94) {-1.25,0.25} Total: 22472 W: 2458 L: 2357 D: 17657 Ptnml(0-2): 106, 1733, 7453, 1842, 102 https://tests.stockfishchess.org/tests/view/5f926cbc81eda81bd78cb6df LTC: LLR: 2.94 (-2.94,2.94) {-0.75,0.25} Total: 37880 W: 1736 L: 1682 D: 34462 Ptnml(0-2): 22, 1392, 16057, 1448, 21 https://tests.stockfishchess.org/tests/view/5f92a26081eda81bd78cb6fe The advantage of using the normal time management for a single legal move is that scores reported for that move are reasonable, not searching leads to artifacts during games (see e.g. https://tcec-chess.com/#div=sf&game=96&season=19) The disadvantage of using normal time management of a single legal move is that thinking times can be unnaturally long, making it 'painful to watch' in online tournaments. This patch uses normal time management, but caps the used time to 500ms. This should lead to reasonable scores, and be hardly perceptible. closes https://github.com/official-stockfish/Stockfish/pull/3195 closes https://github.com/official-stockfish/Stockfish/pull/3183 variant of a patch suggested by SFisGOD No functional change. --- src/search.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 12c32194..6e37fba1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -521,10 +521,14 @@ void Thread::search() { } double bestMoveInstability = 1 + 2 * totBestMoveChanges / Threads.size(); - double totalTime = rootMoves.size() == 1 ? 0 : - Time.optimum() * fallingEval * reduction * bestMoveInstability; + double totalTime = Time.optimum() * fallingEval * reduction * bestMoveInstability; - // Stop the search if we have exceeded the totalTime, at least 1ms search + // Cap used time in case of a single legal move for a better viewer experience in tournaments + // yielding correct scores and sufficiently fast moves. + if (rootMoves.size() == 1) + totalTime = std::min(500.0, totalTime); + + // Stop the search if we have exceeded the totalTime if (Time.elapsed() > totalTime) { // If we are allowed to ponder do not stop the search now but -- 2.39.2