Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Attributes

SgDefaultTimeControl Class Reference

Time management. More...

#include <SgTimeControl.h>

Inheritance diagram for SgDefaultTimeControl:
Inheritance graph
[legend]

List of all members.

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

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 47 of file SgTimeControl.h.


Constructor & Destructor Documentation

SgDefaultTimeControl::SgDefaultTimeControl (  ) 

Definition at line 22 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 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.

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 40 of file SgTimeControl.cpp.

References m_remainingConstant.

void SgDefaultTimeControl::SetFastOpenFactor ( double  factor  ) 

See FastOpenFactor().

Definition at line 50 of file SgTimeControl.cpp.

References m_fastOpenFactor.

void SgDefaultTimeControl::SetFastOpenMoves ( int  nummoves  ) 

See FastOpenMoves().

Definition at line 55 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 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.

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


Member Data Documentation

See FastOpenFactor().

Definition at line 113 of file SgTimeControl.h.

Referenced by FastOpenFactor(), SetFastOpenFactor(), and TimeForCurrentMove().

See FastOpenMoves().

Definition at line 116 of file SgTimeControl.h.

Referenced by FastOpenMoves(), SetFastOpenMoves(), and TimeForCurrentMove().

See SetMinTime().

Definition at line 119 of file SgTimeControl.h.

Referenced by SetMinTime(), and TimeForCurrentMove().


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


Sun Mar 13 2011 Doxygen 1.7.1