Cute Chess 0.1
TimeControl Class Reference

Time controls of a chess game. More...

#include <timecontrol.h>

Public Member Functions

int activeTimeLeft () const
bool expired () const
int expiryMargin () const
void initialize ()
bool isInfinite () const
bool isValid () const
int lastMoveTime () const
int movesLeft () const
int movesPerTc () const
qint64 nodeLimit () const
bool operator== (const TimeControl &other) const
int plyLimit () const
void readSettings (QSettings *settings)
void setExpiryMargin (int expiryMargin)
void setInfinity (bool enabled=true)
void setMovesLeft (int movesLeft)
void setMovesPerTc (int movesPerTc)
void setNodeLimit (qint64 nodes)
void setPlyLimit (int plies)
void setTimeIncrement (int increment)
void setTimeLeft (int timeLeft)
void setTimePerMove (int timePerMove)
void setTimePerTc (int timePerTc)
void startTimer ()
 TimeControl ()
 TimeControl (const QString &str)
int timeIncrement () const
int timeLeft () const
int timePerMove () const
int timePerTc () const
QString toString () const
QString toVerboseString () const
void update (bool applyIncrement=true)
void writeSettings (QSettings *settings)

Detailed Description

Time controls of a chess game.

TimeControl is used for telling the chess players how much time they can spend thinking of their moves.

Note
All time handling is done in milliseconds.

Constructor & Destructor Documentation

◆ TimeControl() [1/2]

TimeControl::TimeControl ( )

Creates a new time control with invalid default settings.

◆ TimeControl() [2/2]

TimeControl::TimeControl ( const QString & str)

Creates a new time control from a string.

str must either be "inf" for infinite time, or it can use the format: movesPerTc/timePerTc+timeIncrement

  • timePerTc is time in seconds if it's a single value. It can also use the form minutes:seconds.
  • if movesPerTc is 0, it should be left out, and the slash character isn't needed.
  • timeIncrement is the time increment per move in seconds. If it's 0, it should be left out along with the plus sign.

Example 1 (40 moves in 120 seconds): TimeControl("40/120");

Example 2 (same as example 1, 40 moves in 2 minutes): TimeControl("40/2:0");

Example 3 (whole game in 2.5 minutes plus 5 sec increment): TimeControl("2:30+5");

Example 4 (infinite thinking time): TimeControl("inf");

Member Function Documentation

◆ activeTimeLeft()

int TimeControl::activeTimeLeft ( ) const

Returns the time left in an active clock.

The TimeControl object doesn't know whether the clock is active or not. It's recommended to check the player's state first to verify that it's in the thinking state.

◆ expired()

bool TimeControl::expired ( ) const

Returns true if the allotted time has expired.

◆ expiryMargin()

int TimeControl::expiryMargin ( ) const

Returns the expiry margin.

Expiry margin is the amount of time a player can go over the time limit without losing on time. The default value is 0.

◆ initialize()

void TimeControl::initialize ( )

Initializes the time control ready for a new game.

◆ isInfinite()

bool TimeControl::isInfinite ( ) const

Returns true if the time control is infinite.

◆ isValid()

bool TimeControl::isValid ( ) const

Returns true if the time control is valid.

◆ lastMoveTime()

int TimeControl::lastMoveTime ( ) const

Returns the last elapsed move time.

◆ movesLeft()

int TimeControl::movesLeft ( ) const

Returns the number of full moves left in the time control, or 0 if the number of moves is not specified.

◆ movesPerTc()

int TimeControl::movesPerTc ( ) const

Returns the number of moves per time control, or 0 if the whole game is played in timePerTc() time.

◆ nodeLimit()

qint64 TimeControl::nodeLimit ( ) const

Returns the node limit for each move.

◆ operator==()

bool TimeControl::operator== ( const TimeControl & other) const

Returns true if other is the same as this time control.

The state of a game (eg. time left, used time, the expiry flag) and the expiry margin are ignored.

◆ plyLimit()

int TimeControl::plyLimit ( ) const

Returns the maximum search depth in plies.

◆ readSettings()

void TimeControl::readSettings ( QSettings * settings)

Reads time control settings from settings.

◆ setExpiryMargin()

void TimeControl::setExpiryMargin ( int expiryMargin)

Sets the expiry margin.

◆ setInfinity()

void TimeControl::setInfinity ( bool enabled = true)

If enabled is true, infinite time control is enabled; otherwise it is disabled.

◆ setMovesLeft()

void TimeControl::setMovesLeft ( int movesLeft)

Sets the number of full moves left in the time control.

◆ setMovesPerTc()

void TimeControl::setMovesPerTc ( int movesPerTc)

Sets the number of moves per time control.

◆ setNodeLimit()

void TimeControl::setNodeLimit ( qint64 nodes)

Sets the node limit.

◆ setPlyLimit()

void TimeControl::setPlyLimit ( int plies)

Sets the maximum search depth in plies.

◆ setTimeIncrement()

void TimeControl::setTimeIncrement ( int increment)

Sets the time increment per move.

◆ setTimeLeft()

void TimeControl::setTimeLeft ( int timeLeft)

Sets the time left in the time control.

◆ setTimePerMove()

void TimeControl::setTimePerMove ( int timePerMove)

Sets the time per move.

◆ setTimePerTc()

void TimeControl::setTimePerTc ( int timePerTc)

Sets the time per time control.

◆ startTimer()

void TimeControl::startTimer ( )

Start the timer.

◆ timeIncrement()

int TimeControl::timeIncrement ( ) const

Returns the time increment per move.

◆ timeLeft()

int TimeControl::timeLeft ( ) const

Returns the time left in the time control.

◆ timePerMove()

int TimeControl::timePerMove ( ) const

Returns the time per move.

The player will think of each move this long at most. Returns 0 if there's no specified total time.

◆ timePerTc()

int TimeControl::timePerTc ( ) const

Returns the time per time control, or 0 if there's no specified total time.

◆ toString()

QString TimeControl::toString ( ) const

Returns the time control string in PGN format.

◆ toVerboseString()

QString TimeControl::toVerboseString ( ) const

Returns a verbose description of the time control.

◆ update()

void TimeControl::update ( bool applyIncrement = true)

Update the time control with the elapsed time. A move time increment will only be applied if applyIncrement is true. This is the default. Set this value to false if no increment is necessary for the current move, e.g. for a book move.

◆ writeSettings()

void TimeControl::writeSettings ( QSettings * settings)

Writes this time control to settings.


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