#include <SgTimeControl.h>
Inheritance diagram for SgDefaultTimeControl:
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 49 of file 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(). |
SgDefaultTimeControl::SgDefaultTimeControl | ( | ) |
Definition at line 23 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 31 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 36 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 41 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 61 of file SgTimeControl.cpp.
References m_minTime.
void SgDefaultTimeControl::SetRemainingConstant | ( | double | value | ) |
See RemainingConstant().
Definition at line 46 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 66 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 120 of file SgTimeControl.h.
Referenced by FastOpenFactor(), SetFastOpenFactor(), and TimeForCurrentMove().
int SgDefaultTimeControl::m_fastOpenMoves [private] |
See FastOpenMoves().
Definition at line 123 of file SgTimeControl.h.
Referenced by FastOpenMoves(), SetFastOpenMoves(), and TimeForCurrentMove().
double SgDefaultTimeControl::m_minTime [private] |
See SetMinTime().
Definition at line 126 of file SgTimeControl.h.
Referenced by SetMinTime(), and TimeForCurrentMove().
double SgDefaultTimeControl::m_remainingConstant [private] |
See RemainingConstant().
Definition at line 129 of file SgTimeControl.h.
Referenced by RemainingConstant(), SetRemainingConstant(), and TimeForCurrentMove().