Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgDefaultTimeControl Class Reference

#include <SgTimeControl.h>

Inheritance diagram for SgDefaultTimeControl:

Inheritance graph
[legend]
List of all members.

Detailed Description

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.

  1. If in an overtime period the remaining number of moves is used exactly as returned by GetPositionInfo().
  2. The time for a move is the remaining time (in the main time or current overtime period) divided by the number of remaining moves.
  3. During the opening (first 10 moves; can be controlled by SetFastOpen()), the time for a move reduced by multiplying it by a constant factor (default factor is 0.25).
  4. [A minimum time of 0.1 is also enforced, but this might become obsolete, see SetMinTime()]
  5. The parameter RemainingConstant() can be used to spend exponentially more time earlier in the game

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().


Constructor & Destructor Documentation

SgDefaultTimeControl::SgDefaultTimeControl (  ) 

Definition at line 23 of file SgTimeControl.cpp.


Member Function Documentation

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.

Parameters:
[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  ) 

See FastOpenFactor().

Definition at line 51 of file SgTimeControl.cpp.

References m_fastOpenFactor.

void SgDefaultTimeControl::SetFastOpenMoves ( int  nummoves  ) 

See FastOpenMoves().

Definition at line 56 of file SgTimeControl.cpp.

References m_fastOpenMoves.

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.

Parameters:
timeRecord Time settings and clock state of current game.
quiet Don't print logging information to SgDebug()
Returns:
Time suggestion for current move in seconds.

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().


Member Data Documentation

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().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7