prevent unproven mated-in scores in game play

This PR removes the variable threads.abortedSearch introduced in #4990 and
relies on threads.stop and completedDepth instead.

The logic in master is only guaranteed to work in single threaded search. For
multiple threads, as soon as threads.stop is set, some of the threads may abort
their search, and so their mated-in scores are not reliable.

Compared to master, this patch prevents unproven mated-in scores in these
multi-threaded scenarios:

    in game play (when time management is used)
    when the uci commands quit or stop are received
    when maximum depth is reached
    for go mate commands

The patch will change the bestmove in those very rare situations where the bug
occurs in master. This is because bestmove is taken from rootMoves[0].pv[0],
which will now no longer contain unproven mated-in PVs. In that sense the patch
is "functional". But of course, it does not change bench.

While at it, we also fix a bug in master that suppressed PV output for inexact
mated-in scores on receiving threads.stop. In cases where uciScore < score with
score not being a proven loss, and where the new bestmove was different from
the last completed iteration, this led to a bestmove output that did not match
the final PV (which was for an exact score).

Fixes #6293.

Fixes #6626.

closes https://github.com/official-stockfish/Stockfish/pull/6636

No functional change
This commit is contained in:
Robert Nurnberg
2026-02-28 11:55:03 +01:00
committed by Joost VandeVondele
parent a6d055d7e2
commit 46ac9a7e6a
3 changed files with 13 additions and 11 deletions
+2 -2
View File
@@ -290,8 +290,8 @@ void ThreadPool::start_thinking(const OptionsMap& options,
main_thread()->wait_for_search_finished();
main_manager()->stopOnPonderhit = stop = abortedSearch = false;
main_manager()->ponder = limits.ponderMode;
main_manager()->stopOnPonderhit = stop = false;
main_manager()->ponder = limits.ponderMode;
increaseDepth = true;