27 m_timeForGame = msPerGame;
32 m_incrementPerMove = 0;
33 m_nTimeLeftForGame = msPerGame;
45 m_timeForGame = msPerGame;
49 m_incrementPerMove = msIncrementPerMove;
51 m_nTimeLeftForGame = msPerGame;
67 m_nTimeForMove = msPerMove;
74 m_nMaxTimeForMove = m_nTimeForMove;
84 m_timeForGame = msPerGame;
85 m_movesPerPeriod = nMoves;
89 m_incrementPerMove = 0;
90 m_nRemainingMovesForPeriod = nMoves;
91 m_nTimeLeftForGame = msPerGame;
100 int const nMoves,
int const msIncrementPerMove)
104 m_movesPerPeriod = nMoves;
105 m_timeForGame = msPerGame;
108 m_incrementPerMove = msIncrementPerMove;
110 m_nRemainingMovesForPeriod = nMoves;
111 m_nTimeLeftForGame = msPerGame;
135 m_nTimeLeftForGame = msPerGame;
137 int nInc = m_incrementPerMove;
138 m_incrementPerMove = 0;
140 m_incrementPerMove = nInc;
145 --m_nRemainingMovesForPeriod;
146 if (m_nRemainingMovesForPeriod < 1)
147 m_nRemainingMovesForPeriod = m_movesPerPeriod;
158 ++m_nRemainingMovesForPeriod;
163void bLevel::recalibrateTime()
168 m_nTimeForMove = m_nTimeLeftForGame / 24;
169 m_nMaxTimeForMove = m_nTimeLeftForGame / 12;
171 if (m_movesPerPeriod) {
173 if (!m_nRemainingMovesForPeriod) {
175 m_nRemainingMovesForPeriod = 1;
177 m_nTimeForMove = (m_nTimeLeftForGame / (m_nRemainingMovesForPeriod + 1)) + m_incrementPerMove;
178 if (m_nRemainingMovesForPeriod > 3) {
179 m_nMaxTimeForMove = (m_nTimeLeftForGame / (m_nRemainingMovesForPeriod/3)) + m_incrementPerMove / 2;
181 m_nMaxTimeForMove = m_nTimeForMove;
185 m_nTimeForMove = (m_nTimeLeftForGame / 20) + m_incrementPerMove;
186 m_nMaxTimeForMove = (m_nTimeLeftForGame / 10) + m_incrementPerMove;
189 if (!m_nRemainingMovesForPeriod) {
191 m_nRemainingMovesForPeriod = 1;
193 if (m_nRemainingMovesForPeriod > 10) {
194 m_nTimeForMove = m_nTimeLeftForGame / m_nRemainingMovesForPeriod;
195 m_nMaxTimeForMove = m_nTimeLeftForGame / (m_nRemainingMovesForPeriod - 5);
197 m_nTimeForMove = m_nTimeLeftForGame / m_nRemainingMovesForPeriod;
198 m_nMaxTimeForMove = m_nTimeForMove;
206 if (m_nTimeForMove > m_nMaxTimeForMove)
207 m_nTimeForMove = m_nMaxTimeForMove;
213 if (m_nAbsoluteAbortTime < m_nMaxTimeForMove) m_nAbsoluteAbortTime = m_nMaxTimeForMove;
215 if (m_nRemainingMovesForPeriod <= 1) {
238void bLevel::adjustQSDepth()
267 if (nTimeElapsed > m_nTimeForMove)
return true;
268 if (nTimeElapsed > m_nAbsoluteAbortTime)
return true;
287 if (nTimeElapsed > m_nEstAllowNextIterationTime)
return false;
299 if (m_nTimeForMove == m_nMaxTimeForMove) {
304 m_nTimeForMove = m_nMaxTimeForMove;
310std::string bLevel::prettyDepth(
depth_t const d)
const
317std::string bLevel::prettyMoves(
int const d)
const
325bLevel::operator std::string()
const
331 +
" for move est/max/abt "
337 +
"/" + prettyMoves(m_movesPerPeriod)
339 +
" Left for #" + prettyMoves(m_nRemainingMovesForPeriod)
341 +
" for move est/max/abt "
349 +
" for move est/max/abt "
355 +
"/" + prettyMoves(m_movesPerPeriod)
356 +
" Left for #" + prettyMoves(m_nRemainingMovesForPeriod)
358 +
" for move est/max/abt "
372 s =
"To be implemented";
This is the main include file, needs to be included before any other include.
bool searchDepthReached(depth_t const d) const
void setGameTime(int const msPerGame)
constexpr depth_t getSearchDepth() const
void setMoreTimeRequired()
increase gradually the allowed time for move, first move to max time for move, then move to abort tim...
void setQSDepth(depth_t const d)
void setRemainingTime(int const msPerGame)
xboard issues time command to update available time
void setMoveTime(int const msPerMove)
void setSearchDepth(depth_t const d)
constexpr bool hasLevelChanged() const
void setMateSearch(depth_t const d)
constexpr depth_t getQSDepth() const
bool qsDepthReached(depth_t const d) const
bool stoppingSearch(long const nTimeElapsed) const
Stop search required ?
void clearLevelChanged()
new level or new game
void setMaxDepth(depth_t const d)
bool stillTimeLeft(depth_t const d, long const nTimeElapsed) const
Do we still have time to do another iteration ?
void setDepthCommand(depth_t const d)
void undoMovePlayed()
used for recalibrating time in case for undo move in xboard moves per period
constexpr depth_t getMaxDepth() const
constexpr auto TIME_OVERFLOWMULTIPLYER
constexpr auto TIME_UNDERFLOWDEVIDER
constexpr depth_t QS_DEPTHEXTENSION
constexpr auto TIME_UNDERFLOWMULTIPLYER
constexpr auto MINIMAL_DEPTH_COMPLETED
constexpr auto TIME_LOSTINENGINE
time lost in between UI go command and bestmove return
constexpr depth_t DEFAULT_DEPTH
constexpr depth_t INFINITE_DEPTH
constexpr auto TIME_LASTMOVEMARGIN
std::string to_string(int16_t value)
std::to_string not compatible on Mac OS (Apple LLVM version 5.0) provide generic utility function
std::string prettyTime(long const t)