Skip to content

Commit

Permalink
Do no initialize TM in all cases
Browse files Browse the repository at this point in the history
Avoid doing full TM initialization if it won't be used, avoids division by zero.

closes #4484

No functional change
  • Loading branch information
maximmasiutin authored and vondele committed Apr 10, 2023
1 parent 7a9f677 commit 1a64afb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/timeman.cpp
Expand Up @@ -36,6 +36,12 @@ TimeManagement Time; // Our global time management object

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"]);
Expand All @@ -59,8 +65,6 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
limits.npmsec = npmsec;
}

startTime = limits.startTime;

// Maximum move horizon of 50 moves
int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50;

Expand Down

0 comments on commit 1a64afb

Please sign in to comment.