X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=b7bead9ff0c867627105cb0eb8ee9ffa328c733e;hp=f5b8b5e275aff3313b74ae061fd8b4455d98dab8;hb=db4cd89cb889446fb349d0d93640b640b1b9a8a1;hpb=db322e6a63459bc3dfdf7fd537d42234b854fb76 diff --git a/src/thread.cpp b/src/thread.cpp index f5b8b5e2..b7bead9f 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -366,15 +366,19 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, Signals.stopOnPonderhit = Signals.firstRootMove = false; Signals.stop = Signals.failedLowAtRoot = false; + RootMoves.clear(); RootPos = pos; Limits = limits; - SetupStates = states; // Ownership transfer here - RootMoves.clear(); + if (states.get()) // If we don't set a new position, preserve current state + { + SetupStates = states; // Ownership transfer here + assert(!states.get()); + } - for (MoveList ml(pos); !ml.end(); ++ml) + for (MoveList it(pos); *it; ++it) if ( searchMoves.empty() - || std::count(searchMoves.begin(), searchMoves.end(), ml.move())) - RootMoves.push_back(RootMove(ml.move())); + || std::count(searchMoves.begin(), searchMoves.end(), *it)) + RootMoves.push_back(RootMove(*it)); main_thread()->thinking = true; main_thread()->notify_one(); // Starts main thread