int MaximumSearchTime, ExtraSearchTime, ExactMaxTime;
bool UseTimeManagement, InfiniteSearch, PonderSearch, StopOnPonderhit;
bool FirstRootMove, AbortSearch, Quit, AspirationFailLow;
+ TimeManager TimeMgr;
// Log file
bool UseLogFile;
int myTime = time[pos.side_to_move()];
int myIncrement = increment[pos.side_to_move()];
if (UseTimeManagement)
- {
- get_search_times(myTime, myIncrement, movesToGo, pos.startpos_ply_counter(),
- &OptimumSearchTime, &MaximumSearchTime);
-
- if (get_option_value_bool("Ponder"))
- {
- OptimumSearchTime += OptimumSearchTime / 4;
- OptimumSearchTime = Min(OptimumSearchTime, MaximumSearchTime);
- }
- }
+ TimeMgr.update(myTime, myIncrement, movesToGo, pos.startpos_ply_counter(),
+ &OptimumSearchTime, &MaximumSearchTime);
// Set best NodesBetweenPolls interval to avoid lagging under
// heavy time pressure.
#include <cmath>
#include "misc.h"
+#include "timeman.h"
#include "ucioption.h"
////
//// Functions
////
-void get_search_times(int myTime, int myInc, int movesToGo, int currentPly,
- int* optimumSearchTime, int* maximumSearchTime)
+void TimeManager::update(int myTime, int myInc, int movesToGo, int currentPly,
+ int* optimumSearchTime, int* maximumSearchTime)
{
/* We support four different kind of time controls:
*maximumSearchTime = Min(*maximumSearchTime, aTime);
}
+ if (get_option_value_bool("Ponder"))
+ *optimumSearchTime += *optimumSearchTime / 4;
+
// Make sure that maxSearchTime is not over absoluteMaxSearchTime
*optimumSearchTime = Min(*optimumSearchTime, *maximumSearchTime);
}
//// Prototypes
////
-void get_search_times(int myTime, int myInc, int movesToGo, int currentPly,
- int* optimumSearchTime, int* maximumSearchTime);
+class TimeManager {
+public:
+
+ void update(int myTime, int myInc, int movesToGo, int currentPly,
+ int* optimumSearchTime, int* maximumSearchTime);
+};
#endif // !defined(TIMEMAN_H_INCLUDED)