|
Cute Chess
0.1
|
Base class for chess tournaments. More...
#include <tournament.h>
Public Slots | |
| void | start () |
| void | stop () |
Signals | |
| void | finished () |
| void | gameFinished (ChessGame *game, int number, int whiteIndex, int blackIndex) |
| void | gameStarted (ChessGame *game, int number, int whiteIndex, int blackIndex) |
Public Member Functions | |
| void | addPlayer (PlayerBuilder *builder, const TimeControl &timeControl, const OpeningBook *book=nullptr, int bookDepth=256) |
| virtual bool | canSetRoundMultiplier () const |
| int | currentRound () const |
| QString | errorString () const |
| int | finalGameCount () const |
| int | finishedGameCount () const |
| GameManager * | gameManager () const |
| int | gamesPerEncounter () const |
| bool | isFinished () const |
| QString | name () const |
| const TournamentPlayer & | playerAt (int index) const |
| int | playerCount () const |
| virtual QString | results () const |
| int | roundMultiplier () const |
| int | seedCount () const |
| void | setAdjudicator (const GameAdjudicator &adjudicator) |
| void | setEpdOutput (const QString &fileName) |
| void | setGamesPerEncounter (int count) |
| void | setName (const QString &name) |
| void | setOpeningBookOwnership (bool enabled) |
| void | setOpeningDepth (int plies) |
| void | setOpeningRepetitions (int count) |
| void | setOpeningSuite (OpeningSuite *suite) |
| void | setPgnCleanupEnabled (bool enabled) |
| void | setPgnOutput (const QString &fileName, PgnGame::PgnMode mode=PgnGame::Verbose) |
| void | setPgnWriteUnfinishedGames (bool enabled) |
| void | setRecoveryMode (bool recover) |
| void | setRoundMultiplier (int factor) |
| void | setSeedCount (int seedCount) |
| void | setSite (const QString &site) |
| void | setStartDelay (int delay) |
| void | setSwapSides (bool enabled) |
| void | setVariant (const QString &variant) |
| QString | site () const |
| Sprt * | sprt () const |
| Tournament (GameManager *gameManager, QObject *parent) | |
| virtual QString | type () const =0 |
| QString | variant () const |
| virtual | ~Tournament () |
Protected Member Functions | |
| virtual void | addScore (int player, int score) |
| virtual bool | areAllGamesFinished () const |
| TournamentPair * | currentPair () const |
| int | gamesInProgress () const |
| virtual int | gamesPerCycle () const =0 |
| virtual bool | hasGauntletRatingsOrder () const |
| virtual void | initializePairing ()=0 |
| virtual TournamentPair * | nextPair (int gameNumber)=0 |
| virtual void | onFinished () |
| virtual void | onGameAboutToStart (ChessGame *game, const PlayerBuilder *white, const PlayerBuilder *black) |
| TournamentPair * | pair (int player1, int player2) |
| int | playerIndex (ChessGame *game, Chess::Side side) const |
| void | setCurrentRound (int round) |
| void | startGame (TournamentPair *pair) |
Base class for chess tournaments.
| Tournament::Tournament | ( | GameManager * | gameManager, |
| QObject * | parent | ||
| ) |
Creates a new tournament that uses gameManager to manage the games.
|
virtual |
Destroys the tournament.
The destructor doesn't end any active games or cleanup their resources. The tournament can be safely destroyed only after the finished() signal is emitted.
| void Tournament::addPlayer | ( | PlayerBuilder * | builder, |
| const TimeControl & | timeControl, | ||
| const OpeningBook * | book = nullptr, |
||
| int | bookDepth = 256 |
||
| ) |
Adds player builder to the tournament.
The player's time control will be timeControl, which may differ from the other players' time controls.
The Tournament object takes ownership of builder and will take care of deleting it.
|
protectedvirtual |
Adds score points to player at index player.
This member function is called when a game ends with a 1-0, 0-1 or 1/2-1/2 result. Subclasses can reimplement this to do their own score tracking.
Reimplemented in KnockoutTournament.
|
protectedvirtual |
Returns true if all games in the tournament have finished; otherwise returns false.
Reimplemented in KnockoutTournament.
|
virtual |
Returns true (default) if the tournament supports user-defined round multiplier; otherwise returns false.
Reimplemented in KnockoutTournament.
|
protected |
Returns the pair that started the last game.
| int Tournament::currentRound | ( | ) | const |
Returns the currently executing round of the tournament.
| QString Tournament::errorString | ( | ) | const |
Returns a detailed description of the error.
| int Tournament::finalGameCount | ( | ) | const |
Returns the total number of games that will be played.
|
signal |
This signal is emitted when all of the tournament's games have been played or after the tournament was stopped.
The tournament can be safely destroyed after this signal is sent.
| int Tournament::finishedGameCount | ( | ) | const |
Returns the number of games finished so far.
|
signal |
This signal is emitted when game game with ordering number number is finished.
The Tournament object deletes the game right after emitting this signal.
whiteIndex is the index to the white player's data blackIndex is the index to the black player's data
| GameManager * Tournament::gameManager | ( | ) | const |
Returns the GameManager that manages the tournament's games.
|
protected |
Returns the number of games in progress.
|
protectedpure virtual |
Returns the number of games in one tournament cycle.
The gamesPerEncounter() and roundMultiplier() values must not affect the number of games per cycle.
Implemented in KnockoutTournament, GauntletTournament, PyramidTournament, and RoundRobinTournament.
| int Tournament::gamesPerEncounter | ( | ) | const |
Returns the number of games to play per encounter.
If the number of games is even then each player is guaranteed to play an equal number of games with white and black pieces.
The default value is 1.
|
signal |
This signal is emitted when game game with ordering number number is started.
whiteIndex is the index to the white player's data blackIndex is the index to the black player's data
|
protectedvirtual |
Returns true if Gauntlet ordering is used for the ratings table (ie. first engine always at the top and the rest ordered by Elo); otherwise returns false.
The default implementation always returns false.
Reimplemented in GauntletTournament.
|
protectedpure virtual |
Initializes the pairings for the tournament.
Subclasses that implement this member function should prepare their data so that the nextPair() function can be called immediately afterwards.
Implemented in KnockoutTournament, GauntletTournament, PyramidTournament, and RoundRobinTournament.
| bool Tournament::isFinished | ( | ) | const |
Returns true if the tournament is finished; otherwise returns false.
| QString Tournament::name | ( | ) | const |
Returns the name of the tournament.
The tournament name will be used as the "Event" tag's value in the resulting PGN data.
|
protectedpure virtual |
Returns the pair of players for the next game.
The pair's first element is the white player's index number and the second element is the black player's index number.
Subclasses that implement this member function should call setCurrentRound() to increase the round when needed. Subclasses should also alternate the colors when needed, to make the tournament as fair as possible.
Sublasses can return (-1, -1) if the next game should not be started yet.
Implemented in KnockoutTournament, GauntletTournament, PyramidTournament, and RoundRobinTournament.
|
protectedvirtual |
Emits the finished() signal.
Subclasses can reimplement this method to add their own cleanup and finalization routines when the tournament ends.
|
protectedvirtual |
This member function is called by startGame() right before the game is actually started.
The default implementation does nothing.
Reimplemented in GauntletTournament.
|
protected |
Returns a tournament pair of player1 and player2.
If a pair with the given players doesn't already exist, one is created.
| const TournamentPlayer & Tournament::playerAt | ( | int | index | ) | const |
Returns player data for the player at index.
| int Tournament::playerCount | ( | ) | const |
Returns the number of participants in the tournament.
|
protected |
Returns the index of player side in game.
|
virtual |
Returns tournament results as a string. The default implementation works for most tournament types.
Reimplemented in KnockoutTournament.
| int Tournament::roundMultiplier | ( | ) | const |
Returns the multiplier for the number of rounds to play.
The default value is 1.
| int Tournament::seedCount | ( | ) | const |
Returns the maximum number of players that can be seeded in the tournament.
| void Tournament::setAdjudicator | ( | const GameAdjudicator & | adjudicator | ) |
Sets the game adjudicator to adjudicator.
The default adjudicator does nothing.
|
protected |
Sets the currently executing tournament round to round.
| void Tournament::setEpdOutput | ( | const QString & | fileName | ) |
Sets the EPD output file for the end positions to fileName.
If no EPD output file is set (default) then the positions will not be saved.
| void Tournament::setGamesPerEncounter | ( | int | count | ) |
Sets the game count per encounter to counter.
counter must be at least 1.
| void Tournament::setName | ( | const QString & | name | ) |
Sets the tournament's name to name.
| void Tournament::setOpeningBookOwnership | ( | bool | enabled | ) |
Sets opening book ownerhip to enabled.
By default the Tournament object doesn't take ownership of its opening books.
| void Tournament::setOpeningDepth | ( | int | plies | ) |
Sets the maximum depth of an opening from the opening suite to plies (halfmoves).
| void Tournament::setOpeningRepetitions | ( | int | count | ) |
Sets the number of opening repetitions to count.
Each opening is played count times before going to the next opening. The default is 1.
| void Tournament::setOpeningSuite | ( | OpeningSuite * | suite | ) |
Uses suite as the opening suite (a collection of openings) for the games.
The tournament takes ownership of suite.
| void Tournament::setPgnCleanupEnabled | ( | bool | enabled | ) |
| void Tournament::setPgnOutput | ( | const QString & | fileName, |
| PgnGame::PgnMode | mode = PgnGame::Verbose |
||
| ) |
Sets the PGN output file for the games to fileName.
The games are saved to the file in mode mode. If no PGN output file is set (default) then the games won't be saved.
| void Tournament::setPgnWriteUnfinishedGames | ( | bool | enabled | ) |
Sets the PgnGame mode to write unfinished games to enabled.
If enabled is true (the default) then the generated PGN games are saved even if they have no result.
| void Tournament::setRecoveryMode | ( | bool | recover | ) |
Sets the recovery mode to recover.
If recover is true then crashed players will will be restarted for the next game; otherwise the whole tournament stops when a player crashes.
| void Tournament::setRoundMultiplier | ( | int | factor | ) |
Sets the multiplier for the number of rounds to factor.
factor must be at least 1.
| void Tournament::setSeedCount | ( | int | seedCount | ) |
Sets the maximum number of players that should be seeded in the tournament.
| void Tournament::setSite | ( | const QString & | site | ) |
Sets the tournament's site to site.
| void Tournament::setStartDelay | ( | int | delay | ) |
Sets the starting delay for each game to delay msec.
| void Tournament::setSwapSides | ( | bool | enabled | ) |
Sets the side swap flag to enabled.
If enabled is true then paired engines will swap sides for the following game.
| void Tournament::setVariant | ( | const QString & | variant | ) |
Sets the games' chess variant to variant.
| QString Tournament::site | ( | ) | const |
Returns the tournament site, ie. the "Site" tag's value.
| Sprt * Tournament::sprt | ( | ) | const |
Returns the SPRT object of this tournament.
Initializing sprt makes this tournament to use it as a stopping criterion.
|
slot |
Starts the tournament.
|
protected |
This member function is called by startNextGame() to start a new tournament game between pair.
Reimplementations should call the base implementation.
|
slot |
Stops the tournament.
Any running games will have an unterminated result. The finished() signal is emitted when the tournament is fully stopped.
|
pure virtual |
Returns the tournament type (eg. "round-robin" or "gauntlet").
Implemented in KnockoutTournament, PyramidTournament, RoundRobinTournament, and GauntletTournament.
| QString Tournament::variant | ( | ) | const |
Returns the games' chess variant.
1.8.11