mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Fix broken UCI 'wait for stop'
When we reach the maximum depth, we can finish the search without a raise of Signals.stop. However, if we are pondering or in an infinite search, the UCI protocol states that we shouldn't print the best move before the GUI sends a "stop" or "ponderhit" command. It was broken by lazy smp. Fix it by moving the stopping of the threads after waiting for GUI. No functional change.
This commit is contained in:
parent
fca8dbc029
commit
ce84ab6e9d
1 changed files with 8 additions and 8 deletions
|
@ -300,14 +300,6 @@ void MainThread::think() {
|
||||||
}
|
}
|
||||||
|
|
||||||
search(true); // Let's start searching!
|
search(true); // Let's start searching!
|
||||||
|
|
||||||
// Stop the threads
|
|
||||||
Signals.stop = true;
|
|
||||||
|
|
||||||
// Wait until all threads have finished
|
|
||||||
for (Thread* th : Threads)
|
|
||||||
if (th != this)
|
|
||||||
th->wait_while(th->searching);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When playing in 'nodes as time' mode, subtract the searched nodes from
|
// When playing in 'nodes as time' mode, subtract the searched nodes from
|
||||||
|
@ -326,6 +318,14 @@ void MainThread::think() {
|
||||||
wait(Signals.stop);
|
wait(Signals.stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop the threads if not already stopped
|
||||||
|
Signals.stop = true;
|
||||||
|
|
||||||
|
// Wait until all threads have finished
|
||||||
|
for (Thread* th : Threads)
|
||||||
|
if (th != this)
|
||||||
|
th->wait_while(th->searching);
|
||||||
|
|
||||||
// Check if there are threads with a better score than main thread.
|
// Check if there are threads with a better score than main thread.
|
||||||
Thread* bestThread = this;
|
Thread* bestThread = this;
|
||||||
for (Thread* th : Threads)
|
for (Thread* th : Threads)
|
||||||
|
|
Loading…
Add table
Reference in a new issue