Monte-Carlo search using UCT for Hex. More...
#include <HexUctSearch.hpp>
Public Member Functions | |
HexUctSearch (SgUctThreadStateFactory *factory, int maxMoves=0) | |
Constructor. | |
~HexUctSearch () | |
Pure virtual functions of SgUctSearch | |
std::string | MoveString (SgMove move) const |
SgUctValue | UnknownEval () const |
SgUctValue | InverseEval (SgUctValue eval) const |
Virtual functions of SgUctSearch | |
void | OnSearchIteration (SgUctValue gameNumber, const unsigned int threadId, const SgUctGameInfo &info) |
void | OnStartSearch () |
Hex-specific functions | |
void | SetBoard (HexBoard &board) |
HexBoard & | Board () |
const HexBoard & | Board () const |
void | SetSharedData (HexUctSharedData &data) |
HexUctSharedData & | SharedData () |
const HexUctSharedData & | SharedData () const |
void | SaveGames (const std::string &fileName) const |
void | AppendGame (const std::vector< SgMove > &sequence) |
Merges last game into the tree of games. | |
void | SaveTree (std::ostream &out, int maxDepth) const |
const StoneBoard & | LastPositionSearched () const |
Returns the position the previous search was run on. | |
Hex-specific parameters | |
void | SetKeepGames (bool enable) |
Keep a SGF tree of all games. | |
bool | KeepGames () const |
void | SetLiveGfx (bool enable) |
Enable output of live graphics commands for HexGui. | |
bool | LiveGfx () const |
void | SetLiveGfxInterval (int interval) |
Set interval for outputting of live graphics commands for HexGui. | |
int | LiveGfxInterval () const |
int | TreeUpdateRadius () const |
Pattern-check radius to use during in-tree phase. | |
void | SetTreeUpdateRadius (int radius) |
See TreeUpdateRadius(). | |
int | PlayoutUpdateRadius () const |
Pattern-check radius to use during playout phase. | |
void | SetPlayoutUpdateRadius (int radius) |
See PlayoutUpdateRadius(). | |
Protected Attributes | |
bool | m_keepGames |
bool | m_liveGfx |
int | m_liveGfxInterval |
int | m_treeUpdateRadius |
int | m_playoutUpdateRadius |
HexBoard * | m_brd |
Nothing is done to this board. | |
HexUctSharedData | m_shared_data |
Data among threads. | |
StoneBoard | m_lastPositionSearched |
SgNode * | m_root |
SgUctValue | m_nextLiveGfx |
Private Member Functions | |
HexUctSearch (const HexUctSearch &search) | |
Not implemented. | |
HexUctSearch & | operator= (const HexUctSearch &search) |
Not implemented. |
Monte-Carlo search using UCT for Hex.
Definition at line 40 of file HexUctSearch.hpp.
HexUctSearch::HexUctSearch | ( | SgUctThreadStateFactory * | factory, | |
int | maxMoves = 0 | |||
) |
Constructor.
factory | Creates HexUctState instances for each thread. | |
maxMoves | Maximum move number. |
Definition at line 50 of file HexUctSearch.cpp.
HexUctSearch::~HexUctSearch | ( | ) |
Definition at line 79 of file HexUctSearch.cpp.
References m_root.
HexUctSearch::HexUctSearch | ( | const HexUctSearch & | search | ) | [private] |
Not implemented.
void HexUctSearch::AppendGame | ( | const std::vector< SgMove > & | sequence | ) |
Merges last game into the tree of games.
Definition at line 87 of file HexUctSearch.cpp.
References HexSgUtil::AddMoveToNode(), HexBoard::Height(), HexAssert, m_brd, m_root, m_shared_data, HexUctSharedData::root_to_play, and HexSgUtil::SgPointToHexPoint().
Referenced by OnSearchIteration().
const HexBoard & HexUctSearch::Board | ( | ) | const [inline] |
Definition at line 211 of file HexUctSearch.hpp.
References m_brd.
HexBoard & HexUctSearch::Board | ( | ) | [inline] |
Definition at line 206 of file HexUctSearch.hpp.
References m_brd.
Referenced by HexUctState::StartSearch().
SgUctValue HexUctSearch::InverseEval | ( | SgUctValue | eval | ) | const |
Definition at line 197 of file HexUctSearch.cpp.
bool HexUctSearch::KeepGames | ( | ) | const [inline] |
Definition at line 216 of file HexUctSearch.hpp.
References m_keepGames.
Referenced by MoHexEngine::MoHexParam().
const StoneBoard & HexUctSearch::LastPositionSearched | ( | ) | const [inline] |
Returns the position the previous search was run on.
Definition at line 282 of file HexUctSearch.hpp.
References m_lastPositionSearched.
bool HexUctSearch::LiveGfx | ( | ) | const [inline] |
Definition at line 221 of file HexUctSearch.hpp.
References m_liveGfx.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
int HexUctSearch::LiveGfxInterval | ( | ) | const [inline] |
Definition at line 226 of file HexUctSearch.hpp.
References m_liveGfxInterval.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
std::string HexUctSearch::MoveString | ( | SgMove | move | ) | const |
Definition at line 202 of file HexUctSearch.cpp.
References HexPointUtil::ToString().
void HexUctSearch::OnSearchIteration | ( | SgUctValue | gameNumber, | |
const unsigned int | threadId, | |||
const SgUctGameInfo & | info | |||
) |
Definition at line 163 of file HexUctSearch.cpp.
References AppendGame(), HexUctUtil::GoGuiGfx(), LogFine(), m_liveGfx, m_liveGfxInterval, m_nextLiveGfx, m_root, m_shared_data, HexUctSharedData::root_to_play, and HexUctUtil::ToSgBlackWhite().
void HexUctSearch::OnStartSearch | ( | ) |
Definition at line 130 of file HexUctSearch.cpp.
References HexBoard::GetPosition(), HexBoard::Height(), HexAssert, m_brd, m_keepGames, m_lastPositionSearched, m_liveGfxInterval, m_nextLiveGfx, m_root, m_shared_data, HexUctSharedData::root_to_play, HexSgUtil::SetPositionInNode(), and HexBoard::Width().
HexUctSearch& HexUctSearch::operator= | ( | const HexUctSearch & | search | ) | [private] |
Not implemented.
int HexUctSearch::PlayoutUpdateRadius | ( | ) | const [inline] |
Pattern-check radius to use during playout phase.
Definition at line 257 of file HexUctSearch.hpp.
References m_playoutUpdateRadius.
Referenced by MoHexPlayer::CopySettingsFrom(), HexThreadStateFactory::Create(), and MoHexEngine::MoHexParam().
void HexUctSearch::SaveGames | ( | const std::string & | fileName | ) | const |
SgException | if KeepGames() was false at last invocation of StartSearch() |
Definition at line 150 of file HexUctSearch.cpp.
References HexBoard::Height(), m_brd, m_root, and HexSgUtil::WriteSgf().
Referenced by MoHexEngine::SaveGames().
void HexUctSearch::SaveTree | ( | std::ostream & | out, | |
int | maxDepth | |||
) | const |
Definition at line 157 of file HexUctSearch.cpp.
References m_lastPositionSearched, m_shared_data, and HexUctSharedData::root_to_play.
Referenced by MoHexEngine::SaveTree().
void HexUctSearch::SetBoard | ( | HexBoard & | board | ) | [inline] |
Definition at line 201 of file HexUctSearch.hpp.
References m_brd.
Referenced by MoHexPlayer::Search().
void HexUctSearch::SetKeepGames | ( | bool | enable | ) | [inline] |
Keep a SGF tree of all games.
Games are cleared in each OnStartSearch(). Games can be saved with SaveGames().
Definition at line 231 of file HexUctSearch.hpp.
References m_keepGames.
Referenced by MoHexEngine::MoHexParam().
void HexUctSearch::SetLiveGfx | ( | bool | enable | ) | [inline] |
Enable output of live graphics commands for HexGui.
Definition at line 236 of file HexUctSearch.hpp.
References m_liveGfx.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
void HexUctSearch::SetLiveGfxInterval | ( | int | interval | ) | [inline] |
Set interval for outputting of live graphics commands for HexGui.
Definition at line 241 of file HexUctSearch.hpp.
References m_liveGfxInterval.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
void HexUctSearch::SetPlayoutUpdateRadius | ( | int | radius | ) | [inline] |
Definition at line 262 of file HexUctSearch.hpp.
References m_playoutUpdateRadius.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
void HexUctSearch::SetSharedData | ( | HexUctSharedData & | data | ) | [inline] |
Definition at line 267 of file HexUctSearch.hpp.
References m_shared_data.
Referenced by MoHexPlayer::Search().
void HexUctSearch::SetTreeUpdateRadius | ( | int | radius | ) | [inline] |
See TreeUpdateRadius().
Definition at line 252 of file HexUctSearch.hpp.
References m_treeUpdateRadius.
Referenced by MoHexPlayer::CopySettingsFrom(), and MoHexEngine::MoHexParam().
const HexUctSharedData & HexUctSearch::SharedData | ( | ) | const [inline] |
Definition at line 277 of file HexUctSearch.hpp.
References m_shared_data.
HexUctSharedData & HexUctSearch::SharedData | ( | ) | [inline] |
Definition at line 272 of file HexUctSearch.hpp.
References m_shared_data.
Referenced by MoHexPlayer::Search(), and HexUctState::StartSearch().
int HexUctSearch::TreeUpdateRadius | ( | ) | const [inline] |
Pattern-check radius to use during in-tree phase.
Definition at line 247 of file HexUctSearch.hpp.
References m_treeUpdateRadius.
Referenced by MoHexPlayer::CopySettingsFrom(), HexThreadStateFactory::Create(), MoHexEngine::MoHexParam(), and MoHexPlayer::Search().
SgUctValue HexUctSearch::UnknownEval | ( | ) | const |
Definition at line 190 of file HexUctSearch.cpp.
HexBoard* HexUctSearch::m_brd [protected] |
Nothing is done to this board.
We do not own this pointer. Threads will synchronise with this board at the start of the search.
Definition at line 176 of file HexUctSearch.hpp.
Referenced by AppendGame(), Board(), OnStartSearch(), SaveGames(), and SetBoard().
bool HexUctSearch::m_keepGames [protected] |
Definition at line 157 of file HexUctSearch.hpp.
Referenced by KeepGames(), OnStartSearch(), and SetKeepGames().
StoneBoard HexUctSearch::m_lastPositionSearched [protected] |
Definition at line 181 of file HexUctSearch.hpp.
Referenced by LastPositionSearched(), OnStartSearch(), and SaveTree().
bool HexUctSearch::m_liveGfx [protected] |
Definition at line 160 of file HexUctSearch.hpp.
Referenced by LiveGfx(), OnSearchIteration(), and SetLiveGfx().
int HexUctSearch::m_liveGfxInterval [protected] |
Definition at line 163 of file HexUctSearch.hpp.
Referenced by LiveGfxInterval(), OnSearchIteration(), OnStartSearch(), and SetLiveGfxInterval().
SgUctValue HexUctSearch::m_nextLiveGfx [protected] |
Definition at line 190 of file HexUctSearch.hpp.
Referenced by OnSearchIteration(), and OnStartSearch().
int HexUctSearch::m_playoutUpdateRadius [protected] |
Definition at line 169 of file HexUctSearch.hpp.
Referenced by PlayoutUpdateRadius(), and SetPlayoutUpdateRadius().
SgNode* HexUctSearch::m_root [protected] |
Definition at line 188 of file HexUctSearch.hpp.
Referenced by AppendGame(), OnSearchIteration(), OnStartSearch(), SaveGames(), and ~HexUctSearch().
HexUctSharedData HexUctSearch::m_shared_data [protected] |
Data among threads.
Definition at line 179 of file HexUctSearch.hpp.
Referenced by AppendGame(), OnSearchIteration(), OnStartSearch(), SaveTree(), SetSharedData(), and SharedData().
int HexUctSearch::m_treeUpdateRadius [protected] |
Definition at line 166 of file HexUctSearch.hpp.
Referenced by SetTreeUpdateRadius(), and TreeUpdateRadius().