#include <Game.hpp>
Public Types | |
enum | ReturnType { INVALID_MOVE, OCCUPIED_CELL, VALID_MOVE } |
Public Member Functions | |
Game (StoneBoard &brd) | |
Creates a new game on the given board. | |
void | NewGame () |
Starts a new game. | |
ReturnType | PlayMove (HexColor color, HexPoint point) |
If move is invalid (color is not BLACK or WHITE, point is an invalid point, point is swap when swap not available) then INVALID_MOVE is returned and game/board is not changed. | |
void | UndoMove () |
The last move is cleared from the board and removed from the game history. | |
double | TimeRemaining (HexColor color) const |
Returns the time remaining for color. | |
void | SetTimeRemaining (HexColor color, double time) |
Sets the time remaining for the given player. | |
StoneBoard & | Board () |
Returns the game board. | |
const StoneBoard & | Board () const |
Returns a constant reference to the game board. | |
void | SetBoard (StoneBoard &brd) |
Change board game is played on. | |
const MoveSequence & | History () const |
Returns the history of moves. | |
bool | AllowSwap () const |
Whether swap move is allowed to be played or not. | |
void | SetAllowSwap (bool enable) |
See SwapAllowed(). | |
double | GameTime () const |
Amount of time given to each player at start of game. | |
void | SetGameTime (double time) |
See GameTime() Can only be called if no moves have been played yet. | |
Private Attributes | |
StoneBoard * | m_board |
MoveSequence | m_history |
double | m_time_remaining [BLACK_AND_WHITE] |
bool | m_allow_swap |
See SwapAllowed(). | |
double | m_game_time |
See GameTime(). |
A Game of Hex.
Definition at line 22 of file Game.hpp.
enum Game::ReturnType |
Game::Game | ( | StoneBoard & | brd | ) | [explicit] |
bool Game::AllowSwap | ( | ) | const [inline] |
Whether swap move is allowed to be played or not.
Definition at line 133 of file Game.hpp.
References m_allow_swap.
Referenced by HexHtpEngine::CmdParamGame(), and SwapCheck::PlaySwap().
const StoneBoard & Game::Board | ( | ) | const [inline] |
StoneBoard & Game::Board | ( | ) | [inline] |
Returns the game board.
Definition at line 103 of file Game.hpp.
References m_board.
Referenced by HexHtpEngine::CmdAllLegalMoves(), HexHtpEngine::CmdBoardID(), BookCommands::CmdBookCounts(), BookCommands::CmdBookDumpPolarizedLeafs(), BookBuilderCommands< PLAYER >::CmdBookExpand(), BookCommands::CmdBookImportSolvedStates(), BookBuilderCommands< PLAYER >::CmdBookIncreaseWidth(), BookCommands::CmdBookMainLineDepth(), BookBuilderCommands< PLAYER >::CmdBookPriorities(), BookBuilderCommands< PLAYER >::CmdBookRefresh(), BookCommands::CmdBookScores(), BookCommands::CmdBookSetValue(), BookCommands::CmdBookVisualize(), VCCommands::CmdBuildStatic(), BenzeneHtpEngine::CmdComputeDominated(), BenzeneHtpEngine::CmdComputeDominatedOnCell(), BenzeneHtpEngine::CmdComputeFillin(), BenzeneHtpEngine::CmdComputeInferior(), BenzeneHtpEngine::CmdComputeReversible(), BenzeneHtpEngine::CmdComputeVulnerable(), BenzeneHtpEngine::CmdEncodePattern(), BenzeneHtpEngine::CmdEvalInfluence(), BenzeneHtpEngine::CmdEvalResistDelta(), BenzeneHtpEngine::CmdEvalTwoDist(), HexHtpEngine::CmdFinalScore(), BenzeneHtpEngine::CmdFindCombDecomp(), BenzeneHtpEngine::CmdFindSplitDecomp(), DfpnCommands::CmdFindWinning(), BenzeneHtpEngine::CmdGetAbsorbGroup(), DfpnCommands::CmdGetBounds(), DfsCommands::CmdGetPV(), DfpnCommands::CmdGetPV(), DfsCommands::CmdGetState(), DfpnCommands::CmdGetState(), DfpnCommands::CmdGetWork(), BenzeneHtpEngine::CmdHandbookAdd(), HexHtpEngine::CmdLoadSgf(), HexHtpEngine::CmdShowboard(), DfsCommands::CmdSolverFindWinning(), DfsCommands::CmdSolveState(), DfpnCommands::CmdSolveState(), MoHexEngine::DoSearch(), WolveEngine::GenMove(), MoHexEngine::GenMove(), BenzeneTestEngine::GenMove(), GameUtil::IsGameOver(), HexHtpEngine::NewGame(), SwapCheck::PlaySwap(), DfpnSolver::PropagateBackwards(), GameUtil::SequenceFromPosition(), and HexHtpEngine::SetPosition().
double Game::GameTime | ( | ) | const [inline] |
Amount of time given to each player at start of game.
Definition at line 143 of file Game.hpp.
References m_game_time.
Referenced by HexHtpEngine::CmdParamGame().
const MoveSequence & Game::History | ( | ) | const [inline] |
Returns the history of moves.
Definition at line 118 of file Game.hpp.
References m_history.
Referenced by BookCommands::CmdBookDumpPolarizedLeafs(), HexHtpEngine::CmdParamGame(), VulPreCheck::KillLastMove(), SwapCheck::PlaySwap(), DfpnSolver::PropagateBackwards(), MoHexPlayer::Search(), HandicapPlayer::Search(), and GameUtil::SequenceFromPosition().
void Game::NewGame | ( | ) |
Starts a new game.
The board and move history are cleared.
Definition at line 21 of file Game.cpp.
References BLACK, LogFine(), m_board, m_game_time, m_history, m_time_remaining, StoneBoard::StartNewGame(), and WHITE.
Referenced by Game(), and HexHtpEngine::NewGame().
Game::ReturnType Game::PlayMove | ( | HexColor | color, | |
HexPoint | point | |||
) |
If move is invalid (color is not BLACK or WHITE, point is an invalid point, point is swap when swap not available) then INVALID_MOVE is returned and game/board is not changed.
If point is occupied, returns CELL_OCCUPIED. Otherwise, returns VALID_MOVE and plays the move to the board and adds it to the game's history.
Definition at line 37 of file Game.cpp.
References StoneBoard::Const(), EMPTY, FIRST_INVALID, INVALID_MOVE, StoneBoard::IsPlayed(), HexPointUtil::isSwap(), ConstBoard::IsValid(), m_allow_swap, m_board, m_history, OCCUPIED_CELL, StoneBoard::PlayMove(), and VALID_MOVE.
Referenced by HexHtpEngine::Play().
void Game::SetAllowSwap | ( | bool | enable | ) | [inline] |
See SwapAllowed().
Definition at line 138 of file Game.hpp.
References m_allow_swap.
Referenced by HexHtpEngine::CmdParamGame().
void Game::SetBoard | ( | StoneBoard & | brd | ) | [inline] |
Change board game is played on.
Definition at line 113 of file Game.hpp.
References m_board.
Referenced by HexHtpEngine::NewGame().
void Game::SetGameTime | ( | double | time | ) |
See GameTime() Can only be called if no moves have been played yet.
Definition at line 30 of file Game.cpp.
References BLACK, m_game_time, m_time_remaining, and WHITE.
Referenced by HexHtpEngine::CmdParamGame().
void Game::SetTimeRemaining | ( | HexColor | color, | |
double | time | |||
) | [inline] |
Sets the time remaining for the given player.
Definition at line 128 of file Game.hpp.
References m_time_remaining.
Referenced by HexHtpEngine::CmdGenMove(), and HexHtpEngine::CmdTimeLeft().
double Game::TimeRemaining | ( | HexColor | color | ) | const [inline] |
Returns the time remaining for color.
Definition at line 123 of file Game.hpp.
References m_time_remaining.
Referenced by HexHtpEngine::CmdGenMove(), HexHtpEngine::CmdTimeLeft(), WolveEngine::TimeForMove(), MoHexEngine::TimeForMove(), and BenzeneTestEngine::TimeForMove().
void Game::UndoMove | ( | ) |
The last move is cleared from the board and removed from the game history.
Does nothing if history is empty.
Definition at line 57 of file Game.cpp.
References m_board, m_history, and StoneBoard::UndoMove().
Referenced by HexHtpEngine::CmdUndo().
bool Game::m_allow_swap [private] |
See SwapAllowed().
Definition at line 97 of file Game.hpp.
Referenced by AllowSwap(), PlayMove(), and SetAllowSwap().
StoneBoard* Game::m_board [private] |
Definition at line 90 of file Game.hpp.
Referenced by Board(), NewGame(), PlayMove(), SetBoard(), and UndoMove().
double Game::m_game_time [private] |
See GameTime().
Definition at line 100 of file Game.hpp.
Referenced by GameTime(), NewGame(), and SetGameTime().
MoveSequence Game::m_history [private] |
Definition at line 92 of file Game.hpp.
Referenced by History(), NewGame(), PlayMove(), and UndoMove().
double Game::m_time_remaining[BLACK_AND_WHITE] [private] |
Definition at line 94 of file Game.hpp.
Referenced by NewGame(), SetGameTime(), SetTimeRemaining(), and TimeRemaining().