mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Stop searching if we cannot find a better move
In a recent CCC event, Stockfish (probably through no fault of its own), lost some games on time when it was winning and when it had already found the move that delivers checkmate. This patch stops the search when TM is active, and when mainthread can be certain that it is impossible to find a better move. That is if (i) it has found mate-in-1, (ii) it has found a mate-in-2 or (iii) it has found a mated-in-1. patch: ``` position fen 5K2/8/2qk4/2nPp3/3r4/6B1/B7/3R4 w - e6 go wtime 100000000 winc 100000000 info string Available processors: 0-7 info string Using 1 thread info string NNUE evaluation using nn-71d6d32cb962.nnue (106MiB, (83248, 1024, 31, 32, 1)) info string Network replica 1: Shared memory. info depth 1 seldepth 3 multipv 1 score mate 1 nodes 30 nps 30000 hashfull 0 tbhits 0 time 1 pv d5e6 bestmove d5e6 ``` master: ``` position fen 5K2/8/2qk4/2nPp3/3r4/6B1/B7/3R4 w - e6 go wtime 100000000 winc 100000000 info string Available processors: 0-7 info string Using 1 thread info string NNUE evaluation using nn-71d6d32cb962.nnue (106MiB, (83248, 1024, 31, 32, 1)) info string Network replica 1: Shared memory. info depth 1 seldepth 3 multipv 1 score mate 1 nodes 30 nps 15000 hashfull 0 tbhits 0 time 2 pv d5e6 <snip> info depth 245 seldepth 2 multipv 1 score mate 1 nodes 5886 nps 367875 hashfull 0 tbhits 0 time 16 pv d5e6 bestmove d5e6 ``` Note: In MultiPV analysis (extremely rare with TM active), we take the point of view that the user would like to continue to search until none of the PVs can be improved anymore. This means we only stop if the worst searched line is at least a mate-in-2, or if the best searched line is a mated-in-1. closes https://github.com/official-stockfish/Stockfish/pull/6879 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
278a755fb5
commit
7b37032885
+4
-2
@@ -583,8 +583,10 @@ bool Search::Worker::iterative_deepening() {
|
|||||||
|
|
||||||
auto elapsedTime = elapsed();
|
auto elapsedTime = elapsed();
|
||||||
|
|
||||||
// Stop the search if we have exceeded the totalTime or maximum
|
// Stop the search if we have exceeded totalTime or maximum time,
|
||||||
if (elapsedTime > std::min(totalTime, double(mainThread->tm.maximum())))
|
// or if we know that there are no better moves in the analysed line(s)
|
||||||
|
if (elapsedTime > std::min(totalTime, double(mainThread->tm.maximum()))
|
||||||
|
|| rootMoves[multiPV - 1].score >= mate_in(3) || rootMoves[0].score == mated_in(2))
|
||||||
{
|
{
|
||||||
// If we are allowed to ponder do not stop the search now but
|
// If we are allowed to ponder do not stop the search now but
|
||||||
// keep pondering until the GUI sends "ponderhit" or "stop".
|
// keep pondering until the GUI sends "ponderhit" or "stop".
|
||||||
|
|||||||
Reference in New Issue
Block a user