Time management. More...
#include <SgTimeControl.h>
Public Member Functions | |
SgDefaultTimeControl () | |
double | TimeForCurrentMove (const SgTimeRecord &timeRecord, bool quiet=false) |
Suggest a time for the current move. | |
virtual void | GetPositionInfo (SgBlackWhite &toPlay, int &movesPlayed, int &estimatedRemainingMoves)=0 |
Get game-specific information about the current position. | |
Parameters | |
double | FastOpenFactor () const |
Set time reduction factor for fast opening moves. | |
void | SetFastOpenFactor (double factor) |
See FastOpenFactor(). | |
int | FastOpenMoves () const |
Set how many opening moves should be played quickly. | |
void | SetFastOpenMoves (int nummoves) |
See FastOpenMoves(). | |
double | RemainingConstant () const |
Parameter to spend exponentially more time earlier in the game. | |
void | SetRemainingConstant (double value) |
See RemainingConstant(). | |
void | SetMinTime (double mintime) |
Set minimum time for any move. | |
Private Attributes | |
double | m_fastOpenFactor |
See FastOpenFactor(). | |
int | m_fastOpenMoves |
See FastOpenMoves(). | |
double | m_minTime |
See SetMinTime(). | |
double | m_remainingConstant |
See RemainingConstant(). |
Time management.
This class provides a reasonable default algorithm for time management. It queries the estimated number of remaining moves by a virtual function that needs to be implemented in the game-dependent subclass.
Definition at line 47 of file SgTimeControl.h.
SgDefaultTimeControl::SgDefaultTimeControl | ( | ) |
Definition at line 22 of file SgTimeControl.cpp.
double SgDefaultTimeControl::FastOpenFactor | ( | ) | const |
Set time reduction factor for fast opening moves.
Default is 0.25. See class description.
Definition at line 30 of file SgTimeControl.cpp.
References m_fastOpenFactor.
int SgDefaultTimeControl::FastOpenMoves | ( | ) | const |
Set how many opening moves should be played quickly.
Default is 0. See class description.
Definition at line 35 of file SgTimeControl.cpp.
References m_fastOpenMoves.
virtual void SgDefaultTimeControl::GetPositionInfo | ( | SgBlackWhite & | toPlay, | |
int & | movesPlayed, | |||
int & | estimatedRemainingMoves | |||
) | [pure virtual] |
Get game-specific information about the current position.
[out] | toPlay | Current color to move. |
[out] | movesPlayed | Moves already played (by the current player) |
[out] | estimatedRemainingMoves | An estimate of the number of remaining moves (for the current player) in the game. |
Referenced by TimeForCurrentMove().
double SgDefaultTimeControl::RemainingConstant | ( | ) | const |
Parameter to spend exponentially more time earlier in the game.
This parameter cuts the number of expected remaining moves from the real expectation to a constant. Always expecting a constant number of remaining moves gives earlier moves more time. Since a good value depends on the average game length and therefore probably the board size, the constant is not given in moves, but as a fraction between 0 and 1, and the constant is computed by multiplication with the expected number of total moves by the current player in the current game (moves played plus expected remaining moves). The default value is 1.0, which does not limit the number of expected remaining moves. The smaller the value, the more time is spent in the early phase of the game.
Definition at line 40 of file SgTimeControl.cpp.
References m_remainingConstant.
void SgDefaultTimeControl::SetFastOpenFactor | ( | double | factor | ) |
void SgDefaultTimeControl::SetFastOpenMoves | ( | int | nummoves | ) |
void SgDefaultTimeControl::SetMinTime | ( | double | mintime | ) |
Set minimum time for any move.
Could be made obsolete? If the player cannot generate a meaningful move in less than a minimum time, he can decide itself to ignore the time limit.
Definition at line 60 of file SgTimeControl.cpp.
References m_minTime.
void SgDefaultTimeControl::SetRemainingConstant | ( | double | value | ) |
See RemainingConstant().
Definition at line 45 of file SgTimeControl.cpp.
References m_remainingConstant.
double SgDefaultTimeControl::TimeForCurrentMove | ( | const SgTimeRecord & | timeRecord, | |
bool | quiet = false | |||
) | [virtual] |
Suggest a time for the current move.
See class description.
timeRecord | Time settings and clock state of current game. | |
quiet | Don't print logging information to SgDebug() |
Implements SgTimeControl.
Definition at line 65 of file SgTimeControl.cpp.
References GetPositionInfo(), m_fastOpenFactor, m_fastOpenMoves, m_minTime, m_remainingConstant, SgTimeRecord::MovesLeft(), SgTimeRecord::OTNumMoves(), SgTimeRecord::OTPeriod(), SgTimeRecord::Overhead(), SgDebug(), SgTimeRecord::TimeLeft(), and SgTimeRecord::UseOvertime().
double SgDefaultTimeControl::m_fastOpenFactor [private] |
See FastOpenFactor().
Definition at line 113 of file SgTimeControl.h.
Referenced by FastOpenFactor(), SetFastOpenFactor(), and TimeForCurrentMove().
int SgDefaultTimeControl::m_fastOpenMoves [private] |
See FastOpenMoves().
Definition at line 116 of file SgTimeControl.h.
Referenced by FastOpenMoves(), SetFastOpenMoves(), and TimeForCurrentMove().
double SgDefaultTimeControl::m_minTime [private] |
See SetMinTime().
Definition at line 119 of file SgTimeControl.h.
Referenced by SetMinTime(), and TimeForCurrentMove().
double SgDefaultTimeControl::m_remainingConstant [private] |
See RemainingConstant().
Definition at line 122 of file SgTimeControl.h.
Referenced by RemainingConstant(), SetRemainingConstant(), and TimeForCurrentMove().