summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c56a7ee)
If we are pondering we will stop the search only when
GUI sends "ponderhit" or "stop" commands or when we reach
maximum depth. In all the other cases we continue to search
so there is no need to verify for available time.
Also better clarify why wait_for_stop_or_ponderhit() before
to exit in some cases.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
int MultiPV, UCIMultiPV, MultiPVIdx;
// Time management variables
int MultiPV, UCIMultiPV, MultiPVIdx;
// Time management variables
- bool StopOnPonderhit, FirstRootMove, StopRequest, QuitRequest, AspirationFailLow;
+ volatile bool StopOnPonderhit, FirstRootMove, StopRequest, QuitRequest, AspirationFailLow;
TimeManager TimeMgr;
SearchLimits Limits;
TimeManager TimeMgr;
SearchLimits Limits;
pos.undo_move(bestMove); // Return from think() with unchanged position
}
pos.undo_move(bestMove); // Return from think() with unchanged position
}
- // If we are pondering or in infinite search, we shouldn't print the best move
+ // When we reach max depth we arrive here even without a StopRequest, but if
+ // we are pondering or in infinite search, we shouldn't print the best move
// before we are told to do so.
// before we are told to do so.
- if (Limits.ponder || Limits.infinite)
+ if (!StopRequest && (Limits.ponder || Limits.infinite))
wait_for_stop_or_ponderhit();
// Could be MOVE_NONE when searching on a stalemate position
wait_for_stop_or_ponderhit();
// Could be MOVE_NONE when searching on a stalemate position
if (depth > 2 && bestMoveChanges[depth])
bestMoveNeverChanged = false;
if (depth > 2 && bestMoveChanges[depth])
bestMoveNeverChanged = false;
- // Check for some early stop condition
- if (!StopRequest && Limits.useTimeManagement())
+ // Do we have time for the next iteration? Can we stop searching now?
+ if (!StopRequest && !StopOnPonderhit && Limits.useTimeManagement())
{
// Take in account some extra time if the best move has changed
if (depth > 4 && depth < 50)
{
// Take in account some extra time if the best move has changed
if (depth > 4 && depth < 50)
}
// If we are allowed to ponder do not stop the search now but keep pondering
}
// If we are allowed to ponder do not stop the search now but keep pondering
- if (StopRequest && Limits.ponder)
+ if (StopRequest && Limits.ponder) // FIXME Limits.ponder is racy
{
StopRequest = false;
StopOnPonderhit = true;
{
StopRequest = false;
StopOnPonderhit = true;