Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

Game Class Reference

A Game of Hex. More...

#include <Game.hpp>

List of all members.

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.
StoneBoardBoard ()
 Returns the game board.
const StoneBoardBoard () const
 Returns a constant reference to the game board.
void SetBoard (StoneBoard &brd)
 Change board game is played on.
const MoveSequenceHistory () 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

StoneBoardm_board
MoveSequence m_history
double m_time_remaining [BLACK_AND_WHITE]
bool m_allow_swap
 See SwapAllowed().
double m_game_time
 See GameTime().

Detailed Description

A Game of Hex.

Todo:
Store time-info in history, so that undoing moves fixes the time remaining.

Definition at line 22 of file Game.hpp.


Member Enumeration Documentation

Enumerator:
INVALID_MOVE 
OCCUPIED_CELL 
VALID_MOVE 

Definition at line 36 of file Game.hpp.


Constructor & Destructor Documentation

Game::Game ( StoneBoard brd  )  [explicit]

Creates a new game on the given board.

Calls NewGame().

Definition at line 13 of file Game.cpp.

References NewGame().


Member Function Documentation

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]

Returns a constant reference to the game board.

Definition at line 108 of file Game.hpp.

References m_board.

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


Member Data Documentation

bool Game::m_allow_swap [private]

See SwapAllowed().

Definition at line 97 of file Game.hpp.

Referenced by AllowSwap(), PlayMove(), and SetAllowSwap().

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

Definition at line 92 of file Game.hpp.

Referenced by History(), NewGame(), PlayMove(), and UndoMove().

Definition at line 94 of file Game.hpp.

Referenced by NewGame(), SetGameTime(), SetTimeRemaining(), and TimeRemaining().


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


6 Jan 2011 Doxygen 1.6.3