mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Revert "Fix a race on Limits::ponder"
This reverts commit 5410424e3d
.
After the commit pondering is broken, so revert for now. I will
resubmit with a proper fix.
The issue is mine, Joost original code is correct.
No functional change.
This commit is contained in:
parent
5410424e3d
commit
44236f4ed9
5 changed files with 11 additions and 10 deletions
|
@ -277,7 +277,7 @@ void MainThread::search() {
|
|||
// the UCI protocol states that we shouldn't print the best move before the
|
||||
// GUI sends a "stop" or "ponderhit" command. We therefore simply wait here
|
||||
// until the GUI sends one of those commands (which also raises Threads.stop).
|
||||
if (!Threads.stop && (Threads.ponder || Limits.infinite))
|
||||
if (!Threads.stop && (Limits.ponder || Limits.infinite))
|
||||
{
|
||||
Threads.stopOnPonderhit = true;
|
||||
wait(Threads.stop);
|
||||
|
@ -499,7 +499,7 @@ void Thread::search() {
|
|||
{
|
||||
// If we are allowed to ponder do not stop the search now but
|
||||
// keep pondering until the GUI sends "ponderhit" or "stop".
|
||||
if (Threads.ponder)
|
||||
if (Limits.ponder)
|
||||
Threads.stopOnPonderhit = true;
|
||||
else
|
||||
Threads.stop = true;
|
||||
|
@ -1489,7 +1489,7 @@ moves_loop: // When in check search starts from here
|
|||
}
|
||||
|
||||
// An engine may not stop pondering until told so by the GUI
|
||||
if (Threads.ponder)
|
||||
if (Limits.ponder)
|
||||
return;
|
||||
|
||||
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|
||||
|
|
|
@ -72,13 +72,14 @@ typedef std::vector<RootMove> RootMoves;
|
|||
|
||||
|
||||
/// LimitsType struct stores information sent by GUI about available time to
|
||||
/// search the current move, maximum depth/time, or if we are in analysis mode.
|
||||
/// search the current move, maximum depth/time, if we are in analysis mode or
|
||||
/// if we have to ponder while it's our opponent's turn to move.
|
||||
|
||||
struct LimitsType {
|
||||
|
||||
LimitsType() { // Init explicitly due to broken value-initialization of non POD in MSVC
|
||||
nodes = time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] =
|
||||
npmsec = movestogo = depth = movetime = mate = infinite = 0;
|
||||
npmsec = movestogo = depth = movetime = mate = infinite = ponder = 0;
|
||||
}
|
||||
|
||||
bool use_time_management() const {
|
||||
|
@ -86,7 +87,7 @@ struct LimitsType {
|
|||
}
|
||||
|
||||
std::vector<Move> searchmoves;
|
||||
int time[COLOR_NB], inc[COLOR_NB], npmsec, movestogo, depth, movetime, mate, infinite;
|
||||
int time[COLOR_NB], inc[COLOR_NB], npmsec, movestogo, depth, movetime, mate, infinite, ponder;
|
||||
int64_t nodes;
|
||||
TimePoint startTime;
|
||||
};
|
||||
|
|
|
@ -187,7 +187,7 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
|
|||
|
||||
main()->wait_for_search_finished();
|
||||
|
||||
ponder = stopOnPonderhit = stop = false;
|
||||
stopOnPonderhit = stop = false;
|
||||
Search::Limits = limits;
|
||||
Search::RootMoves rootMoves;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ struct ThreadPool : public std::vector<Thread*> {
|
|||
uint64_t nodes_searched() const;
|
||||
uint64_t tb_hits() const;
|
||||
|
||||
std::atomic_bool stop, ponder, stopOnPonderhit;
|
||||
std::atomic_bool stop, stopOnPonderhit;
|
||||
|
||||
private:
|
||||
StateListPtr setupStates;
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace {
|
|||
else if (token == "movetime") is >> limits.movetime;
|
||||
else if (token == "mate") is >> limits.mate;
|
||||
else if (token == "infinite") limits.infinite = 1;
|
||||
else if (token == "ponder") Threads.ponder = true;
|
||||
else if (token == "ponder") limits.ponder = 1;
|
||||
|
||||
Threads.start_thinking(pos, States, limits);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void UCI::loop(int argc, char* argv[]) {
|
|||
Threads.main()->start_searching(true); // Could be sleeping
|
||||
}
|
||||
else if (token == "ponderhit")
|
||||
Threads.ponder = false; // Switch to normal search
|
||||
Search::Limits.ponder = 0; // Switch to normal search
|
||||
|
||||
else if (token == "uci")
|
||||
sync_cout << "id name " << engine_info(true)
|
||||
|
|
Loading…
Add table
Reference in a new issue