Time.availableNodes += Limits.inc[us] - Threads.nodes_searched();
// When we reach the maximum depth, we can arrive here without a raise of
Time.availableNodes += Limits.inc[us] - Threads.nodes_searched();
// When we reach the maximum depth, we can arrive here without a raise of
// 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
// 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 Signals.stop).
- if (!Signals.stop && (Limits.ponder || Limits.infinite))
+ // until the GUI sends one of those commands (which also raises Threads.stop).
+ if (!Threads.stop && (Limits.ponder || Limits.infinite))
multiPV = std::min(multiPV, rootMoves.size());
// Iterative deepening loop until requested to stop or the target depth is reached
multiPV = std::min(multiPV, rootMoves.size());
// Iterative deepening loop until requested to stop or the target depth is reached
- while ( (rootDepth = rootDepth + ONE_PLY) < DEPTH_MAX
- && !Signals.stop
- && (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
+ while ( (rootDepth += ONE_PLY) < DEPTH_MAX
+ && !Threads.stop
+ && !(Limits.depth && mainThread && rootDepth / ONE_PLY > Limits.depth))
// If search has been stopped, we break immediately. Sorting and
// writing PV back to TT is safe because RootMoves is still
// valid, although it refers to the previous iteration.
// If search has been stopped, we break immediately. Sorting and
// writing PV back to TT is safe because RootMoves is still
// valid, although it refers to the previous iteration.
sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl;
}
sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl;
}
// Do we have time for the next iteration? Can we stop searching now?
if (Limits.use_time_management())
{
// Do we have time for the next iteration? Can we stop searching now?
if (Limits.use_time_management())
{
{
// Stop the search if only one legal move is available, or if all
// of the available time has been used, or if we matched an easyMove
{
// Stop the search if only one legal move is available, or if all
// of the available time has been used, or if we matched an easyMove
// If we are allowed to ponder do not stop the search now but
// keep pondering until the GUI sends "ponderhit" or "stop".
if (Limits.ponder)
// If we are allowed to ponder do not stop the search now but
// keep pondering until the GUI sends "ponderhit" or "stop".
if (Limits.ponder)
// Finished searching the move. If a stop occurred, the return value of
// the search cannot be trusted, and we return immediately without
// updating best move, PV and TT.
// Finished searching the move. If a stop occurred, the return value of
// the search cannot be trusted, and we return immediately without
// updating best move, PV and TT.
// completed. But in this case bestValue is valid because we have fully
// searched our subtree, and we can anyhow save the result in TT.
/*
// completed. But in this case bestValue is valid because we have fully
// searched our subtree, and we can anyhow save the result in TT.
/*
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|| (Limits.movetime && elapsed >= Limits.movetime)
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|| (Limits.movetime && elapsed >= Limits.movetime)
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))