Basic htp commands any Hex engine is required to support. More...
#include <HexHtpEngine.hpp>
Public Member Functions | |
HexHtpEngine (int boardsize) | |
~HexHtpEngine () | |
Command Callbacks | |
virtual void | CmdAllLegalMoves (HtpCommand &cmd) |
Returns a list of all legal moves on current board position. | |
virtual void | CmdBoardID (HtpCommand &) |
Outputs BoardID of current position. | |
virtual void | CmdClearBoard (HtpCommand &cmd) |
Starts a new game with the same board size. | |
virtual void | CmdExec (HtpCommand &cmd) |
Executes HTP commands contained in given file. | |
virtual void | CmdFinalScore (HtpCommand &cmd) |
Returns a string with what we think the outcome of the game is. | |
virtual void | CmdGenMove (HtpCommand &cmd) |
Generates a move and handles time remaining. | |
virtual void | CmdRegGenMove (HtpCommand &cmd) |
Generates a move, but does not play it. | |
virtual void | CmdLoadSgf (HtpCommand &cmd) |
Loads game or position from given sgf. | |
virtual void | CmdName (HtpCommand &) |
Returns program's name. | |
virtual void | CmdNewGame (HtpCommand &cmd) |
Starts new game with the given board size. | |
virtual void | CmdParamGame (HtpCommand &cmd) |
Displays/changes parameters relating to the current game. | |
virtual void | CmdPlay (HtpCommand &) |
Plays a move. | |
virtual void | CmdShowboard (HtpCommand &) |
Displays the board. | |
virtual void | CmdTimeLeft (HtpCommand &) |
Displays time left for both players or given player. | |
virtual void | CmdUndo (HtpCommand &cmd) |
Undo the last move. | |
virtual void | CmdVersion (HtpCommand &) |
Returns program's version. | |
Protected Member Functions | |
void | BeforeHandleCommand () |
Clears SgAbortFlag(). | |
void | BeforeWritingResponse () |
Does nothing. | |
virtual void | Play (HexColor color, HexPoint move) |
Plays a move. | |
virtual void | NewGame (int width, int height) |
Creates a new game on a board with given dimensions. | |
virtual HexPoint | GenMove (HexColor color, bool useGameClock)=0 |
Generates a move for color. | |
void | SetPosition (const SgNode *node) |
Protected Attributes | |
StoneBoard | m_board |
Game | m_game |
Private Member Functions | |
void | RegisterCmd (const std::string &name, GtpCallback< HexHtpEngine >::Method method) |
Basic htp commands any Hex engine is required to support.
Definition at line 26 of file HexHtpEngine.hpp.
HexHtpEngine::HexHtpEngine | ( | int | boardsize | ) |
Definition at line 32 of file HexHtpEngine.cpp.
References CmdAllLegalMoves(), CmdBoardID(), CmdClearBoard(), CmdExec(), CmdFinalScore(), CmdGenMove(), CmdLoadSgf(), CmdName(), CmdNewGame(), CmdParamGame(), CmdPlay(), CmdRegGenMove(), CmdShowboard(), CmdTimeLeft(), CmdUndo(), CmdVersion(), StoneBoard::Height(), m_board, NewGame(), RegisterCmd(), and StoneBoard::Width().
HexHtpEngine::~HexHtpEngine | ( | ) |
Definition at line 60 of file HexHtpEngine.cpp.
void HexHtpEngine::BeforeHandleCommand | ( | ) | [protected] |
Clears SgAbortFlag().
Definition at line 107 of file HexHtpEngine.cpp.
void HexHtpEngine::BeforeWritingResponse | ( | ) | [protected] |
Does nothing.
Definition at line 112 of file HexHtpEngine.cpp.
void HexHtpEngine::CmdAllLegalMoves | ( | HtpCommand & | cmd | ) | [virtual] |
Returns a list of all legal moves on current board position.
Definition at line 281 of file HexHtpEngine.cpp.
References Game::Board(), StoneBoard::GetLegal(), and m_game.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdBoardID | ( | HtpCommand & | cmd | ) | [virtual] |
Outputs BoardID of current position.
Definition at line 236 of file HexHtpEngine.cpp.
References Game::Board(), StoneBoard::GetBoardIDString(), and m_game.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdClearBoard | ( | HtpCommand & | cmd | ) | [virtual] |
Starts a new game with the same board size.
Definition at line 169 of file HexHtpEngine.cpp.
References StoneBoard::Height(), m_board, NewGame(), and StoneBoard::Width().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdExec | ( | HtpCommand & | cmd | ) | [virtual] |
Executes HTP commands contained in given file.
Definition at line 131 of file HexHtpEngine.cpp.
References LogInfo().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdFinalScore | ( | HtpCommand & | cmd | ) | [virtual] |
Returns a string with what we think the outcome of the game is.
Value will be "B+" for a black win, and "W+" for a white win.
Definition at line 267 of file HexHtpEngine.cpp.
References BLACK, Game::Board(), GroupBuilder::Build(), Groups::GetWinner(), m_game, and WHITE.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdGenMove | ( | HtpCommand & | cmd | ) | [virtual] |
Generates a move and handles time remaining.
Definition at line 183 of file HexHtpEngine.cpp.
References HtpUtil::ColorArg(), GenMove(), GameUtil::IsGameOver(), LogWarning(), m_game, Play(), RESIGN, Game::SetTimeRemaining(), and Game::TimeRemaining().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdLoadSgf | ( | HtpCommand & | cmd | ) | [virtual] |
Loads game or position from given sgf.
Sets position to given move number or the last move of the game if none is given.
Definition at line 311 of file HexHtpEngine.cpp.
References Game::Board(), StoneBoard::Height(), LogWarning(), m_game, NewGame(), HexSgUtil::NodeHasSetupInfo(), Play(), SetPosition(), HexSgUtil::SgColorToHexColor(), and HexSgUtil::SgPointToHexPoint().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdName | ( | HtpCommand & | cmd | ) | [virtual] |
Returns program's name.
Definition at line 119 of file HexHtpEngine.cpp.
References Get().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdNewGame | ( | HtpCommand & | cmd | ) | [virtual] |
Starts new game with the given board size.
Definition at line 156 of file HexHtpEngine.cpp.
References MAX_HEIGHT, MAX_WIDTH, and NewGame().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdParamGame | ( | HtpCommand & | cmd | ) | [virtual] |
Displays/changes parameters relating to the current game.
Parameters:
allow_swap
See Game::AllowSwap game_time
See Game::GameTime Definition at line 371 of file HexHtpEngine.cpp.
References Game::AllowSwap(), Game::GameTime(), Game::History(), m_game, Game::SetAllowSwap(), and Game::SetGameTime().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdPlay | ( | HtpCommand & | cmd | ) | [virtual] |
Plays a move.
Definition at line 176 of file HexHtpEngine.cpp.
References HtpUtil::ColorArg(), HtpUtil::MoveArg(), and Play().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdRegGenMove | ( | HtpCommand & | cmd | ) | [virtual] |
Generates a move, but does not play it.
Sets random seed.
Definition at line 208 of file HexHtpEngine.cpp.
References HtpUtil::ColorArg(), GenMove(), GameUtil::IsGameOver(), m_game, and RESIGN.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdShowboard | ( | HtpCommand & | cmd | ) | [virtual] |
Displays the board.
Definition at line 229 of file HexHtpEngine.cpp.
References Game::Board(), and m_game.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdTimeLeft | ( | HtpCommand & | cmd | ) | [virtual] |
Displays time left for both players or given player.
Definition at line 243 of file HexHtpEngine.cpp.
References BLACK, HtpUtil::ColorArg(), Time::Formatted(), m_game, Game::SetTimeRemaining(), Game::TimeRemaining(), and WHITE.
Referenced by HexHtpEngine().
void HexHtpEngine::CmdUndo | ( | HtpCommand & | cmd | ) | [virtual] |
Undo the last move.
Definition at line 222 of file HexHtpEngine.cpp.
References m_game, and Game::UndoMove().
Referenced by HexHtpEngine().
void HexHtpEngine::CmdVersion | ( | HtpCommand & | cmd | ) | [virtual] |
Returns program's version.
Definition at line 125 of file HexHtpEngine.cpp.
References Get().
Referenced by HexHtpEngine().
virtual HexPoint HexHtpEngine::GenMove | ( | HexColor | color, | |
bool | useGameClock | |||
) | [protected, pure virtual] |
Generates a move for color.
Implemented in BenzeneTestEngine, MoHexEngine, and WolveEngine.
Referenced by CmdGenMove(), and CmdRegGenMove().
void HexHtpEngine::NewGame | ( | int | width, | |
int | height | |||
) | [protected, virtual] |
Creates a new game on a board with given dimensions.
Reimplemented in BenzeneHtpEngine.
Definition at line 96 of file HexHtpEngine.cpp.
References Game::Board(), StoneBoard::Height(), m_board, m_game, Game::NewGame(), Game::SetBoard(), and StoneBoard::Width().
Referenced by CmdClearBoard(), CmdLoadSgf(), CmdNewGame(), and HexHtpEngine().
Plays a move.
Definition at line 72 of file HexHtpEngine.cpp.
References Game::INVALID_MOVE, m_game, Game::OCCUPIED_CELL, Game::PlayMove(), and RESIGN.
Referenced by CmdGenMove(), CmdLoadSgf(), CmdPlay(), and SetPosition().
void HexHtpEngine::RegisterCmd | ( | const std::string & | name, | |
GtpCallback< HexHtpEngine >::Method | method | |||
) | [private] |
Definition at line 66 of file HexHtpEngine.cpp.
Referenced by HexHtpEngine().
void HexHtpEngine::SetPosition | ( | const SgNode * | node | ) | [protected] |
Definition at line 293 of file HexHtpEngine.cpp.
References BLACK, Game::Board(), HexSgUtil::GetSetupPosition(), StoneBoard::Height(), m_game, Play(), and WHITE.
Referenced by CmdLoadSgf().
StoneBoard HexHtpEngine::m_board [protected] |
Definition at line 86 of file HexHtpEngine.hpp.
Referenced by CmdClearBoard(), HexHtpEngine(), and NewGame().
Game HexHtpEngine::m_game [protected] |
Definition at line 88 of file HexHtpEngine.hpp.
Referenced by CmdAllLegalMoves(), CmdBoardID(), BenzeneHtpEngine::CmdComputeDominated(), BenzeneHtpEngine::CmdComputeDominatedOnCell(), BenzeneHtpEngine::CmdComputeFillin(), BenzeneHtpEngine::CmdComputeInferior(), BenzeneHtpEngine::CmdComputeReversible(), BenzeneHtpEngine::CmdComputeVulnerable(), BenzeneHtpEngine::CmdEncodePattern(), BenzeneHtpEngine::CmdEvalInfluence(), BenzeneHtpEngine::CmdEvalResistDelta(), BenzeneHtpEngine::CmdEvalTwoDist(), CmdFinalScore(), BenzeneHtpEngine::CmdFindCombDecomp(), BenzeneHtpEngine::CmdFindSplitDecomp(), CmdGenMove(), BenzeneHtpEngine::CmdGetAbsorbGroup(), BenzeneHtpEngine::CmdHandbookAdd(), CmdLoadSgf(), CmdParamGame(), CmdRegGenMove(), CmdShowboard(), CmdTimeLeft(), CmdUndo(), MoHexEngine::DoSearch(), WolveEngine::GenMove(), MoHexEngine::GenMove(), BenzeneTestEngine::GenMove(), NewGame(), Play(), SetPosition(), WolveEngine::TimeForMove(), MoHexEngine::TimeForMove(), and BenzeneTestEngine::TimeForMove().