Avoid doing full TM initialization if it won't be used, avoids division by zero.
closes https://github.com/official-stockfish/Stockfish/pull/4484
No functional change
void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
+ // if we have no time, no need to initialize TM, except for the start time,
+ // which is used by movetime.
+ startTime = limits.startTime;
+ if (limits.time[us] == 0)
+ return;
+
TimePoint moveOverhead = TimePoint(Options["Move Overhead"]);
TimePoint slowMover = TimePoint(Options["Slow Mover"]);
TimePoint npmsec = TimePoint(Options["nodestime"]);
TimePoint moveOverhead = TimePoint(Options["Move Overhead"]);
TimePoint slowMover = TimePoint(Options["Slow Mover"]);
TimePoint npmsec = TimePoint(Options["nodestime"]);
limits.npmsec = npmsec;
}
limits.npmsec = npmsec;
}
- startTime = limits.startTime;
-
// Maximum move horizon of 50 moves
int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50;
// Maximum move horizon of 50 moves
int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50;