Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

MoHexEngine Class Reference

Htp engine for MoHex. More...

#include <MoHexEngine.hpp>

Inheritance diagram for MoHexEngine:
BenzeneHtpEngine HexHtpEngine

List of all members.

Public Member Functions

 MoHexEngine (int boardsize, MoHexPlayer &player)
 ~MoHexEngine ()
double TimeForMove (HexColor color)
Command Callbacks

void MoHexParam (HtpCommand &cmd)
void MoHexPolicyParam (HtpCommand &cmd)
void SaveTree (HtpCommand &cmd)
 Saves the search tree from the previous search to the specified file.
void SaveGames (HtpCommand &cmd)
 Saves games from last search to a SGF.
void Values (HtpCommand &cmd)
void RaveValues (HtpCommand &cmd)
void Bounds (HtpCommand &cmd)
Command Callbacks

void CmdLicense (HtpCommand &cmd)
 Displays usage license.
void CmdGetAbsorbGroup (HtpCommand &cmd)
 Returns the set of stones this stone is part of.
void CmdHandbookAdd (HtpCommand &cmd)
 Pulls moves out of the game for given color and appends them to the given handbook file.
void CmdComputeInferior (HtpCommand &cmd)
 Outputs inferior cell info for current state.
void CmdComputeFillin (HtpCommand &cmd)
 Computes fillin for the given board.
void CmdComputeVulnerable (HtpCommand &cmd)
 Computes vulnerable cells on the current board for the given color.
void CmdComputeReversible (HtpCommand &cmd)
 Computes reversible cells on the current board for the given color.
void CmdComputeDominated (HtpCommand &cmd)
 Computes dominated cells on the current board for the given color.
void CmdComputeDominatedOnCell (HtpCommand &cmd)
void CmdFindCombDecomp (HtpCommand &cmd)
 Tries to find a combinatorial decomposition of the board state.
void CmdFindSplitDecomp (HtpCommand &cmd)
 Tries to find a group that crowds both opponent edges.
void CmdEncodePattern (HtpCommand &cmd)
 Outputs pattern in encoded form.
void CmdParamDfpn (HtpCommand &cmd)
void CmdEvalTwoDist (HtpCommand &cmd)
void CmdEvalResist (HtpCommand &cmd)
void CmdEvalResistDelta (HtpCommand &cmd)
void CmdEvalInfluence (HtpCommand &cmd)
void CmdMiscDebug (HtpCommand &cmd)
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

virtual void NewGame (int width, int height)
 Creates a new game on a board with given dimensions.
void ParamPlayer (BenzenePlayer *player, HtpCommand &cmd)
void BeforeHandleCommand ()
 Clears SgAbortFlag().
void BeforeWritingResponse ()
 Does nothing.
virtual void Play (HexColor color, HexPoint move)
 Plays a move.
void SetPosition (const SgNode *node)

Protected Attributes

HexEnvironment m_pe
 Player's environment.
HexEnvironment m_se
 Solver's environment.
DfsSolver m_dfsSolver
DfpnSolver m_dfpnSolver
boost::scoped_ptr< DfsHashTablem_dfsHashTable
boost::scoped_ptr< DfpnHashTablem_dfpnHashTable
boost::scoped_ptr< DfsDBm_dfsDB
boost::scoped_ptr< DfpnDBm_dfpnDB
SolverDBParameters m_dfsParam
SolverDBParameters m_dfpnParam
SolverDB< DfsHashTable, DfsDB,
DfsData
m_dfsPositions
SolverDB< DfpnHashTable,
DfpnDB, DfpnData
m_dfpnPositions
HexEnvironmentCommands m_playerEnvCommands
HexEnvironmentCommands m_solverEnvCommands
VCCommands m_vcCommands
DfsCommands m_dfsSolverCommands
DfpnCommands m_dfpnSolverCommands
bool m_useParallelSolver
StoneBoard m_board
Game m_game

Private Member Functions

HexPoint GenMove (HexColor color, bool useGameClock)
 Generates a move for color.
HexPoint DoSearch (HexColor color, double maxTime)
void RegisterCmd (const std::string &name, GtpCallback< MoHexEngine >::Method method)

Private Attributes

MoHexPlayerm_player
boost::scoped_ptr< Bookm_book
BookCheck m_bookCheck
BookBuilderCommands< MoHexPlayerm_bookCommands

Detailed Description

Htp engine for MoHex.

Definition at line 19 of file MoHexEngine.hpp.


Constructor & Destructor Documentation

MoHexEngine::MoHexEngine ( int  boardsize,
MoHexPlayer player 
)
MoHexEngine::~MoHexEngine (  ) 

Definition at line 69 of file MoHexEngine.cpp.


Member Function Documentation

void HexHtpEngine::BeforeHandleCommand (  )  [protected, inherited]

Clears SgAbortFlag().

Definition at line 107 of file HexHtpEngine.cpp.

void HexHtpEngine::BeforeWritingResponse (  )  [protected, inherited]

Does nothing.

Definition at line 112 of file HexHtpEngine.cpp.

void MoHexEngine::Bounds ( HtpCommand cmd  ) 

Definition at line 340 of file MoHexEngine.cpp.

References m_player, and MoHexPlayer::Search().

Referenced by MoHexEngine().

void HexHtpEngine::CmdAllLegalMoves ( HtpCommand cmd  )  [virtual, inherited]

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 HexHtpEngine::m_game.

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdBoardID ( HtpCommand cmd  )  [virtual, inherited]

Outputs BoardID of current position.

Definition at line 236 of file HexHtpEngine.cpp.

References Game::Board(), StoneBoard::GetBoardIDString(), and HexHtpEngine::m_game.

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdClearBoard ( HtpCommand cmd  )  [virtual, inherited]

Starts a new game with the same board size.

Definition at line 169 of file HexHtpEngine.cpp.

References StoneBoard::Height(), HexHtpEngine::m_board, HexHtpEngine::NewGame(), and StoneBoard::Width().

Referenced by HexHtpEngine::HexHtpEngine().

void BenzeneHtpEngine::CmdComputeDominated ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdComputeDominatedOnCell ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdComputeFillin ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdComputeInferior ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdComputeReversible ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdComputeVulnerable ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdEncodePattern ( HtpCommand cmd  )  [inherited]

Outputs pattern in encoded form.

Takes a list of cells, the first cell being the center of the pattern (that is not actually in the pattern). FIXME: clean this up!

Definition at line 363 of file BenzeneHtpEngine.cpp.

References Game::Board(), HexPointUtil::DeltaX(), HexPointUtil::DeltaY(), HexAssert, LogInfo(), HexHtpEngine::m_game, Pattern::MAX_EXTENSION, HtpUtil::MoveArg(), NUM_DIRECTIONS, Pattern::NUM_SLICES, and HexPointUtil::pointToCoords().

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

void BenzeneHtpEngine::CmdEvalInfluence ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdEvalResist ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdEvalResistDelta ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdEvalTwoDist ( HtpCommand cmd  )  [inherited]
void HexHtpEngine::CmdExec ( HtpCommand cmd  )  [virtual, inherited]

Executes HTP commands contained in given file.

Definition at line 131 of file HexHtpEngine.cpp.

References LogInfo().

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdFinalScore ( HtpCommand cmd  )  [virtual, inherited]

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(), HexHtpEngine::m_game, and WHITE.

Referenced by HexHtpEngine::HexHtpEngine().

void BenzeneHtpEngine::CmdFindCombDecomp ( HtpCommand cmd  )  [inherited]

Tries to find a combinatorial decomposition of the board state.

Outputs cells in the vc if there is a decomposition. Usage: 'find-comb-decomp [color]'

Definition at line 324 of file BenzeneHtpEngine.cpp.

References BLACK, Game::Board(), HtpUtil::ColorArg(), HexBoard::ComputeAll(), BoardUtils::FindCombinatorialDecomposition(), HexHtpEngine::m_game, BenzeneHtpEngine::m_pe, HexBoard::SetUseDecompositions(), HexEnvironment::SyncBoard(), HexPointUtil::ToString(), and HexBoard::UseDecompositions().

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

void BenzeneHtpEngine::CmdFindSplitDecomp ( HtpCommand cmd  )  [inherited]

Tries to find a group that crowds both opponent edges.

Outputs group that crowds both edges if one exists. Usage: 'find-split-decomp [color]'

FIXME: Dump inferior cell info as well? It's hard to see what's actually going on if it is not displayed.

Definition at line 347 of file BenzeneHtpEngine.cpp.

References BLACK, Game::Board(), HtpUtil::ColorArg(), HexBoard::ComputeAll(), BoardUtils::FindSplittingDecomposition(), HexHtpEngine::m_game, BenzeneHtpEngine::m_pe, and HexEnvironment::SyncBoard().

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

void HexHtpEngine::CmdGenMove ( HtpCommand cmd  )  [virtual, inherited]
void BenzeneHtpEngine::CmdGetAbsorbGroup ( HtpCommand cmd  )  [inherited]
void BenzeneHtpEngine::CmdHandbookAdd ( HtpCommand cmd  )  [inherited]

Pulls moves out of the game for given color and appends them to the given handbook file.

Skips the first move (ie, the move from the empty board). Performs no duplicate checking. Usage: handbook-add [handbook.txt] [sgf file] [color] [max move #]

Definition at line 148 of file BenzeneHtpEngine.cpp.

References Game::Board(), HtpUtil::ColorArg(), FIRST_TO_PLAY, StoneBoard::Height(), HexAssert, HexHtpEngine::m_game, HexSgUtil::NodeHasSetupInfo(), HexSgUtil::SgColorToHexColor(), HexSgUtil::SgPointToHexPoint(), HashUtil::toString(), and StoneBoard::Width().

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

void BenzeneHtpEngine::CmdLicense ( HtpCommand cmd  )  [inherited]

Displays usage license.

Definition at line 107 of file BenzeneHtpEngine.cpp.

References Get().

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

void HexHtpEngine::CmdLoadSgf ( HtpCommand cmd  )  [virtual, inherited]

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(), HexHtpEngine::m_game, HexHtpEngine::NewGame(), HexSgUtil::NodeHasSetupInfo(), HexHtpEngine::Play(), HexHtpEngine::SetPosition(), HexSgUtil::SgColorToHexColor(), and HexSgUtil::SgPointToHexPoint().

Referenced by HexHtpEngine::HexHtpEngine().

void BenzeneHtpEngine::CmdMiscDebug ( HtpCommand cmd  )  [inherited]
void HexHtpEngine::CmdName ( HtpCommand cmd  )  [virtual, inherited]

Returns program's name.

Definition at line 119 of file HexHtpEngine.cpp.

References Get().

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdNewGame ( HtpCommand cmd  )  [virtual, inherited]

Starts new game with the given board size.

Definition at line 156 of file HexHtpEngine.cpp.

References MAX_HEIGHT, MAX_WIDTH, and HexHtpEngine::NewGame().

Referenced by HexHtpEngine::HexHtpEngine().

void BenzeneHtpEngine::CmdParamDfpn ( HtpCommand cmd  )  [inherited]
void HexHtpEngine::CmdParamGame ( HtpCommand cmd  )  [virtual, inherited]

Displays/changes parameters relating to the current game.

Parameters:

Definition at line 371 of file HexHtpEngine.cpp.

References Game::AllowSwap(), Game::GameTime(), Game::History(), HexHtpEngine::m_game, Game::SetAllowSwap(), and Game::SetGameTime().

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdPlay ( HtpCommand cmd  )  [virtual, inherited]

Plays a move.

Definition at line 176 of file HexHtpEngine.cpp.

References HtpUtil::ColorArg(), HtpUtil::MoveArg(), and HexHtpEngine::Play().

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdRegGenMove ( HtpCommand cmd  )  [virtual, inherited]

Generates a move, but does not play it.

Sets random seed.

Definition at line 208 of file HexHtpEngine.cpp.

References HtpUtil::ColorArg(), HexHtpEngine::GenMove(), GameUtil::IsGameOver(), HexHtpEngine::m_game, and RESIGN.

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdShowboard ( HtpCommand cmd  )  [virtual, inherited]

Displays the board.

Definition at line 229 of file HexHtpEngine.cpp.

References Game::Board(), and HexHtpEngine::m_game.

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdTimeLeft ( HtpCommand cmd  )  [virtual, inherited]

Displays time left for both players or given player.

Definition at line 243 of file HexHtpEngine.cpp.

References BLACK, HtpUtil::ColorArg(), Time::Formatted(), HexHtpEngine::m_game, Game::SetTimeRemaining(), Game::TimeRemaining(), and WHITE.

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdUndo ( HtpCommand cmd  )  [virtual, inherited]

Undo the last move.

Definition at line 222 of file HexHtpEngine.cpp.

References HexHtpEngine::m_game, and Game::UndoMove().

Referenced by HexHtpEngine::HexHtpEngine().

void HexHtpEngine::CmdVersion ( HtpCommand cmd  )  [virtual, inherited]

Returns program's version.

Definition at line 125 of file HexHtpEngine.cpp.

References Get().

Referenced by HexHtpEngine::HexHtpEngine().

HexPoint MoHexEngine::DoSearch ( HexColor  color,
double  maxTime 
) [private]
HexPoint MoHexEngine::GenMove ( HexColor  color,
bool  useGameClock 
) [private, virtual]
void MoHexEngine::MoHexParam ( HtpCommand cmd  ) 
void MoHexEngine::MoHexPolicyParam ( HtpCommand cmd  ) 
void BenzeneHtpEngine::NewGame ( int  width,
int  height 
) [protected, virtual, inherited]

Creates a new game on a board with given dimensions.

Reimplemented from HexHtpEngine.

Definition at line 94 of file BenzeneHtpEngine.cpp.

References BenzeneHtpEngine::m_pe, BenzeneHtpEngine::m_se, and HexEnvironment::NewGame().

void BenzeneHtpEngine::ParamPlayer ( BenzenePlayer player,
HtpCommand cmd 
) [protected, inherited]
void HexHtpEngine::Play ( HexColor  color,
HexPoint  move 
) [protected, virtual, inherited]
void MoHexEngine::RaveValues ( HtpCommand cmd  ) 

Definition at line 325 of file MoHexEngine.cpp.

References m_player, and MoHexPlayer::Search().

Referenced by MoHexEngine().

void MoHexEngine::RegisterCmd ( const std::string &  name,
GtpCallback< MoHexEngine >::Method  method 
) [private]

Definition at line 75 of file MoHexEngine.cpp.

Referenced by MoHexEngine().

void MoHexEngine::SaveGames ( HtpCommand cmd  ) 

Saves games from last search to a SGF.

Definition at line 299 of file MoHexEngine.cpp.

References m_player, HexUctSearch::SaveGames(), and MoHexPlayer::Search().

Referenced by MoHexEngine().

void MoHexEngine::SaveTree ( HtpCommand cmd  ) 

Saves the search tree from the previous search to the specified file.

The optional second parameter sets the max depth to output. If not given, entire tree is saved.

Definition at line 283 of file MoHexEngine.cpp.

References m_player, HexUctSearch::SaveTree(), and MoHexPlayer::Search().

Referenced by MoHexEngine().

void HexHtpEngine::SetPosition ( const SgNode *  node  )  [protected, inherited]
Bug:
This won't work if we're overwriting previosly played stones!

Definition at line 293 of file HexHtpEngine.cpp.

References BLACK, Game::Board(), HexSgUtil::GetSetupPosition(), StoneBoard::Height(), HexHtpEngine::m_game, HexHtpEngine::Play(), and WHITE.

Referenced by HexHtpEngine::CmdLoadSgf().

double MoHexEngine::TimeForMove ( HexColor  color  ) 
void MoHexEngine::Values ( HtpCommand cmd  ) 

Definition at line 307 of file MoHexEngine.cpp.

References m_player, and MoHexPlayer::Search().

Referenced by MoHexEngine().


Member Data Documentation

StoneBoard HexHtpEngine::m_board [protected, inherited]
boost::scoped_ptr<Book> MoHexEngine::m_book [private]

Definition at line 54 of file MoHexEngine.hpp.

Definition at line 56 of file MoHexEngine.hpp.

Referenced by GenMove().

Definition at line 58 of file MoHexEngine.hpp.

Referenced by MoHexEngine().

boost::scoped_ptr<DfpnDB> BenzeneHtpEngine::m_dfpnDB [protected, inherited]

Definition at line 101 of file BenzeneHtpEngine.hpp.

boost::scoped_ptr<DfpnHashTable> BenzeneHtpEngine::m_dfpnHashTable [protected, inherited]

Definition at line 97 of file BenzeneHtpEngine.hpp.

Definition at line 105 of file BenzeneHtpEngine.hpp.

Definition at line 119 of file BenzeneHtpEngine.hpp.

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

boost::scoped_ptr<DfsDB> BenzeneHtpEngine::m_dfsDB [protected, inherited]

Definition at line 99 of file BenzeneHtpEngine.hpp.

boost::scoped_ptr<DfsHashTable> BenzeneHtpEngine::m_dfsHashTable [protected, inherited]

Definition at line 95 of file BenzeneHtpEngine.hpp.

Definition at line 103 of file BenzeneHtpEngine.hpp.

Definition at line 107 of file BenzeneHtpEngine.hpp.

DfsSolver BenzeneHtpEngine::m_dfsSolver [protected, inherited]

Definition at line 91 of file BenzeneHtpEngine.hpp.

Definition at line 117 of file BenzeneHtpEngine.hpp.

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

Game HexHtpEngine::m_game [protected, inherited]
HexEnvironment BenzeneHtpEngine::m_pe [protected, inherited]

Definition at line 111 of file BenzeneHtpEngine.hpp.

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

HexEnvironment BenzeneHtpEngine::m_se [protected, inherited]

Solver's environment.

Definition at line 89 of file BenzeneHtpEngine.hpp.

Referenced by DoSearch(), WolveEngine::GenMove(), and BenzeneHtpEngine::NewGame().

Definition at line 113 of file BenzeneHtpEngine.hpp.

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().

bool BenzeneHtpEngine::m_useParallelSolver [protected, inherited]

Definition at line 115 of file BenzeneHtpEngine.hpp.

Referenced by BenzeneHtpEngine::BenzeneHtpEngine().


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


6 Jan 2011 Doxygen 1.6.3