Full board Monte-Carlo tree search. More...
#include <GoUctGlobalSearch.h>
Public Member Functions | |
GoUctGlobalSearch (GoBoard &bd, FACTORY *playoutPolicyFactory, const GoUctPlayoutPolicyParam &policyParam) | |
Constructor. | |
void | SetDefaultParameters (int boardSize) |
Set default search parameters optimized for a board size. | |
bool | GlobalSearchLiveGfx () const |
Output live graphics commands for GoGui. | |
void | SetGlobalSearchLiveGfx (bool enable) |
See GlobalSearchLiveGfx(). | |
void | SetThreadStateFactory (SgUctThreadStateFactory *factory) |
SgUctThreadState & | ThreadState (int i) const |
bool | ThreadsCreated () const |
void | CreateThreads () |
virtual void | OnEndSearch () |
virtual void | OnThreadStartSearch (SgUctThreadState &state) |
virtual void | OnThreadEndSearch (SgUctThreadState &state) |
virtual SgUctValue | GamesPlayed () const |
void | GenerateAllMoves (std::vector< SgUctMoveInfo > &moves) |
void | PlayGame () |
void | StartSearch (const std::vector< SgMove > &rootFilter=std::vector< SgMove >(), SgUctTree *initTree=0) |
void | EndSearch () |
SgUctValue | Search (SgUctValue maxGames, double maxTime, std::vector< SgMove > &sequence, const std::vector< SgMove > &rootFilter=std::vector< SgMove >(), SgUctTree *initTree=0, SgUctEarlyAbortParam *earlyAbort=0) |
SgPoint | SearchOnePly (SgUctValue maxGames, double maxTime, SgUctValue &value) |
const SgUctNode * | FindBestChild (const SgUctNode &node, const std::vector< SgMove > *excludeMoves=0) const |
void | FindBestSequence (std::vector< SgMove > &sequence) const |
SgUctValue | GetBound (bool useRave, const SgUctNode &node, const SgUctNode &child) const |
const SgUctGameInfo & | LastGameInfo () const |
std::string | LastGameSummaryLine () const |
bool | WasEarlyAbort () const |
const SgUctTree & | Tree () const |
SgUctTree & | GetTempTree () |
float | BiasTermConstant () const |
void | SetBiasTermConstant (float biasTermConstant) |
std::vector< SgUctValue > | KnowledgeThreshold () const |
void | SetKnowledgeThreshold (const std::vector< SgUctValue > &counts) |
std::size_t | MaxNodes () const |
void | SetMaxNodes (std::size_t maxNodes) |
unsigned int | NumberThreads () const |
void | SetNumberThreads (unsigned int n) |
bool | LockFree () const |
void | SetLockFree (bool enable) |
int | RandomizeRaveFrequency () const |
void | SetRandomizeRaveFrequency (int frequency) |
bool | RaveCheckSame () const |
void | SetRaveCheckSame (bool enable) |
SgUctValue | FirstPlayUrgency () const |
void | SetFirstPlayUrgency (SgUctValue firstPlayUrgency) |
bool | LogGames () const |
void | SetLogGames (bool enable) |
std::size_t | MaxGameLength () const |
void | SetMaxGameLength (std::size_t maxGameLength) |
SgUctValue | ExpandThreshold () const |
void | SetExpandThreshold (SgUctValue expandThreshold) |
std::size_t | NumberPlayouts () const |
void | SetNumberPlayouts (std::size_t n) |
bool | Rave () const |
void | SetRave (bool enable) |
SgUctMoveSelect | MoveSelect () const |
void | SetMoveSelect (SgUctMoveSelect moveSelect) |
float | RaveWeightInitial () const |
void | SetRaveWeightInitial (float value) |
float | RaveWeightFinal () const |
void | SetRaveWeightFinal (float value) |
bool | WeightRaveUpdates () const |
void | SetWeightRaveUpdates (bool enable) |
bool | VirtualLoss () const |
void | SetVirtualLoss (bool enable) |
bool | PruneFullTree () const |
void | SetPruneFullTree (bool enable) |
SgUctValue | PruneMinCount () const |
void | SetPruneMinCount (SgUctValue n) |
bool | CheckFloatPrecision () const |
void | SetCheckFloatPrecision (bool enable) |
void | SetMpiSynchronizer (const SgMpiSynchronizerHandle &synchronizerHandle) |
SgMpiSynchronizerHandle | MpiSynchronizer () |
const SgMpiSynchronizerHandle | MpiSynchronizer () const |
const SgUctSearchStat & | Statistics () const |
void | WriteStatistics (std::ostream &out) const |
Pure virtual functions of SgUctSearch | |
SgUctValue | UnknownEval () const |
Virtual functions of SgUctSearch | |
void | OnStartSearch () |
void | DisplayGfx () |
Pure virtual functions of SgUctSearch | |
std::string | MoveString (SgMove move) const |
SgBlackWhite | ToPlay () const |
Color to play at the root node of the last search. | |
Virtual functions of SgUctSearch | |
void | OnSearchIteration (SgUctValue gameNumber, unsigned int threadId, const SgUctGameInfo &info) |
Go-specific functions | |
GoBoard & | Board () |
const GoBoard & | Board () const |
void | SaveGames (const std::string &fileName) const |
See SetKeepGames(). | |
void | SaveTree (std::ostream &out, int maxDepth=-1) const |
See GoUctUtil::SaveTree(). | |
void | SetToPlay (SgBlackWhite toPlay) |
Set initial color to play. | |
const GoBoardHistory & | BoardHistory () const |
Identifier for the position the last search was performed on. | |
Go-specific parameters | |
bool | KeepGames () const |
Keep a SGF tree of all games. | |
void | SetKeepGames (bool enable) |
See KeepGames(). | |
GoUctLiveGfx | LiveGfx () const |
Output live graphics commands for GoGui. | |
void | SetLiveGfx (GoUctLiveGfx mode) |
See LiveGfx(). | |
SgUctValue | LiveGfxInterval () const |
Interval for outputting of live graphics commands for GoGui. | |
void | SetLiveGfxInterval (SgUctValue interval) |
See LiveGfxInterval(). | |
Static Public Member Functions | |
static SgUctValue | InverseEval (SgUctValue eval) |
static SgUctValue | InverseEstimate (SgUctValue eval) |
Public Attributes | |
GoUctGlobalSearchStateParam | m_param |
Private Attributes | |
SgBWSet | m_safe |
SgPointArray< bool > | m_allSafe |
boost::scoped_ptr< FACTORY > | m_playoutPolicyFactory |
GoRegionBoard | m_regions |
bool | m_globalSearchLiveGfx |
See GlobalSearchLiveGfx(). |
Full board Monte-Carlo tree search.
POLICY | The playout policy | |
FACTORY | The factory for the playout policy |
Definition at line 580 of file GoUctGlobalSearch.h.
GoUctGlobalSearch< POLICY, FACTORY >::GoUctGlobalSearch | ( | GoBoard & | bd, | |
FACTORY * | playoutPolicyFactory, | |||
const GoUctPlayoutPolicyParam & | policyParam | |||
) |
Constructor.
bd | ||
playoutPolicyFactory | Creates multiple instances of the playout policies. Takes ownership. playoutPolicyFactory should not have SetSafe() and SetAllSafe() already set, because the search will call these functions using its own safety information. | |
policyParam |
Definition at line 643 of file GoUctGlobalSearch.h.
References SgUctSearch::LockFree(), GoUctGlobalSearch< POLICY, FACTORY >::m_allSafe, GoUctGlobalSearch< POLICY, FACTORY >::m_safe, GoUctGlobalSearch< POLICY, FACTORY >::SetDefaultParameters(), SgUctSearch::SetNumberThreads(), SgUctSearch::SetThreadStateFactory(), and SgDebug().
GoBoard & GoUctSearch::Board | ( | ) | [inherited] |
Definition at line 277 of file GoUctSearch.h.
References GoUctSearch::m_bd.
Referenced by GoUctEstimatorStat::Compute(), GoUctGlobalSearchStateFactory< POLICY, FACTORY >::Create(), GoUctGlobalSearch< POLICY, FACTORY >::DisplayGfx(), GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch(), and GoUctSearchUtil::TrompTaylorPassCheck().
const GoBoard & GoUctSearch::Board | ( | ) | const [inherited] |
Definition at line 282 of file GoUctSearch.h.
References GoUctSearch::m_bd.
const GoBoardHistory & GoUctSearch::BoardHistory | ( | ) | const [inherited] |
Identifier for the position the last search was performed on.
Definition at line 287 of file GoUctSearch.h.
References GoUctSearch::m_boardHistory.
void GoUctGlobalSearch< POLICY, FACTORY >::DisplayGfx | ( | ) | [virtual] |
Reimplemented from GoUctSearch.
Definition at line 685 of file GoUctGlobalSearch.h.
References GoUctSearch::Board(), GoUctUtil::GfxBestMove(), GoUctUtil::GfxStatus(), GoUctUtil::GfxTerritoryStatistics(), GoUctGlobalSearch< POLICY, FACTORY >::m_globalSearchLiveGfx, GoUctGlobalSearchState< POLICY >::m_territoryStatistics, SgDebug(), SgUctSearch::ThreadState(), and GoUctSearch::ToPlay().
bool GoUctGlobalSearch< POLICY, FACTORY >::GlobalSearchLiveGfx | ( | ) | const |
Output live graphics commands for GoGui.
Similar to the GOUCT_LIVEGFX_COUNTS mode in GoUctSearch, but the influence data shows the terriroy statistics (which must be enabled) instead of the move values. No move counts are shown. The live graphics interval from GoUctSearch will be used.
Definition at line 679 of file GoUctGlobalSearch.h.
References GoUctGlobalSearch< POLICY, FACTORY >::m_globalSearchLiveGfx.
Referenced by GoUctCommands::CmdParamGlobalSearch().
bool GoUctSearch::KeepGames | ( | ) | const [inherited] |
Keep a SGF tree of all games.
This is reset in OnStartSearch() and can be saved with SaveGames().
Definition at line 292 of file GoUctSearch.h.
References GoUctSearch::m_keepGames.
Referenced by GoUctCommands::CmdParamSearch().
GoUctLiveGfx GoUctSearch::LiveGfx | ( | ) | const [inherited] |
Output live graphics commands for GoGui.
If enabled, LiveGfx commands for GoGui are outputted to the debug stream every n games. Note that GoUctUtil::GoGuiGfx() outputs values as influence data and assumes values in [0:1].
Definition at line 297 of file GoUctSearch.h.
References GoUctSearch::m_liveGfx.
Referenced by GoUctCommands::CmdParamSearch().
SgUctValue GoUctSearch::LiveGfxInterval | ( | ) | const [inherited] |
Interval for outputting of live graphics commands for GoGui.
Default is every 5000 games.
Definition at line 302 of file GoUctSearch.h.
References GoUctSearch::m_liveGfxInterval.
Referenced by GoUctCommands::CmdParamSearch().
std::string GoUctSearch::MoveString | ( | SgMove | move | ) | const [virtual, inherited] |
Implements SgUctSearch.
Definition at line 191 of file GoUctSearch.cpp.
References SgPointUtil::PointToString().
void GoUctSearch::OnSearchIteration | ( | SgUctValue | gameNumber, | |
unsigned int | threadId, | |||
const SgUctGameInfo & | info | |||
) | [virtual, inherited] |
Reimplemented from SgUctSearch.
Definition at line 196 of file GoUctSearch.cpp.
References GoUctSearch::DisplayGfx(), GOUCT_LIVEGFX_NONE, SgUctSearch::LockFree(), GoUctSearch::m_liveGfx, GoUctSearch::m_liveGfxInterval, GoUctSearch::m_nextLiveGfx, GoUctSearch::m_root, and GoUctSearch::m_toPlay.
void GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch | ( | ) | [virtual] |
Reimplemented from GoUctSearch.
Definition at line 702 of file GoUctGlobalSearch.h.
References GoUctSearch::Board(), SgBWSet::Clear(), SgPointArray< T >::Fill(), GoSafetySolver::FindSafePoints(), GOUCT_USE_SAFETY_SOLVER, GoUctGlobalSearch< POLICY, FACTORY >::m_allSafe, GoUctGlobalSearch< POLICY, FACTORY >::m_globalSearchLiveGfx, GoUctGlobalSearch< POLICY, FACTORY >::m_param, GoUctGlobalSearch< POLICY, FACTORY >::m_regions, GoUctGlobalSearch< POLICY, FACTORY >::m_safe, GoUctGlobalSearchStateParam::m_territoryStatistics, SgBWSet::OneContains(), and SgWarning().
void GoUctSearch::SaveGames | ( | const std::string & | fileName | ) | const [inherited] |
See SetKeepGames().
SgException | if KeepGames() was false at last invocation of StartSearch() |
Definition at line 264 of file GoUctSearch.cpp.
References GoUctSearch::m_root, and SgUctSearch::MpiSynchronizer().
Referenced by GoUctCommands::CmdSaveGames().
void GoUctSearch::SaveTree | ( | std::ostream & | out, | |
int | maxDepth = -1 | |||
) | const [inherited] |
Definition at line 276 of file GoUctSearch.cpp.
References GoUctSearch::m_bd, GoUctSearch::m_stones, GoUctSearch::m_toPlay, GoBoard::Size(), and SgUctSearch::Tree().
Referenced by GoUctCommands::CmdSaveTree().
void GoUctGlobalSearch< POLICY, FACTORY >::SetDefaultParameters | ( | int | boardSize | ) |
Set default search parameters optimized for a board size.
Definition at line 722 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchStateParam::m_lengthModification, GoUctGlobalSearch< POLICY, FACTORY >::m_param, SgUctSearch::SetBiasTermConstant(), SgUctSearch::SetExpandThreshold(), SgUctSearch::SetFirstPlayUrgency(), SgUctSearch::SetMoveSelect(), SgUctSearch::SetRave(), SgUctSearch::SetRaveWeightFinal(), SgUctSearch::SetRaveWeightInitial(), SgUctSearch::SetVirtualLoss(), and SG_UCTMOVESELECT_COUNT.
Referenced by GoUctGlobalSearch< POLICY, FACTORY >::GoUctGlobalSearch().
void GoUctGlobalSearch< POLICY, FACTORY >::SetGlobalSearchLiveGfx | ( | bool | enable | ) |
Definition at line 750 of file GoUctGlobalSearch.h.
References GoUctGlobalSearch< POLICY, FACTORY >::m_globalSearchLiveGfx.
Referenced by GoUctCommands::CmdParamGlobalSearch().
void GoUctSearch::SetKeepGames | ( | bool | enable | ) | [inherited] |
See KeepGames().
Definition at line 307 of file GoUctSearch.h.
References GoUctSearch::m_keepGames.
Referenced by GoUctCommands::CmdParamSearch().
void GoUctSearch::SetLiveGfx | ( | GoUctLiveGfx | mode | ) | [inherited] |
See LiveGfx().
Definition at line 312 of file GoUctSearch.h.
References GoUctSearch::m_liveGfx.
Referenced by GoUctCommands::CmdParamSearch().
void GoUctSearch::SetLiveGfxInterval | ( | SgUctValue | interval | ) | [inherited] |
See LiveGfxInterval().
Definition at line 317 of file GoUctSearch.h.
References GoUctSearch::m_liveGfxInterval, and SG_ASSERT.
Referenced by GoUctCommands::CmdParamSearch().
void GoUctSearch::SetToPlay | ( | SgBlackWhite | toPlay | ) | [inherited] |
Set initial color to play.
Definition at line 323 of file GoUctSearch.h.
References GoUctSearch::m_bd, GoUctSearch::m_toPlay, and GoBoard::SetToPlay().
SgBlackWhite GoUctSearch::ToPlay | ( | ) | const [inherited] |
Color to play at the root node of the last search.
Definition at line 282 of file GoUctSearch.cpp.
References GoUctSearch::m_toPlay.
Referenced by GoUctCommands::CmdGfx(), GoUctGlobalSearch< POLICY, FACTORY >::DisplayGfx(), and GoUctSearchUtil::TrompTaylorPassCheck().
SgUctValue GoUctGlobalSearch< POLICY, FACTORY >::UnknownEval | ( | ) | const [virtual] |
Implements SgUctSearch.
Definition at line 757 of file GoUctGlobalSearch.h.
SgPointArray<bool> GoUctGlobalSearch< POLICY, FACTORY >::m_allSafe [private] |
Definition at line 632 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearch< POLICY, FACTORY >::GoUctGlobalSearch(), and GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch().
bool GoUctGlobalSearch< POLICY, FACTORY >::m_globalSearchLiveGfx [private] |
Definition at line 639 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearch< POLICY, FACTORY >::DisplayGfx(), GoUctGlobalSearch< POLICY, FACTORY >::GlobalSearchLiveGfx(), GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch(), and GoUctGlobalSearch< POLICY, FACTORY >::SetGlobalSearchLiveGfx().
GoUctGlobalSearchStateParam GoUctGlobalSearch< POLICY, FACTORY >::m_param |
Definition at line 584 of file GoUctGlobalSearch.h.
Referenced by GoUctCommands::CmdParamGlobalSearch(), GoUctGlobalSearchStateFactory< POLICY, FACTORY >::Create(), GoUctCommands::DoFinalStatusSearch(), GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch(), and GoUctGlobalSearch< POLICY, FACTORY >::SetDefaultParameters().
boost::scoped_ptr<FACTORY> GoUctGlobalSearch< POLICY, FACTORY >::m_playoutPolicyFactory [private] |
Definition at line 634 of file GoUctGlobalSearch.h.
GoRegionBoard GoUctGlobalSearch< POLICY, FACTORY >::m_regions [private] |
Definition at line 636 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch().
SgBWSet GoUctGlobalSearch< POLICY, FACTORY >::m_safe [private] |
Definition at line 630 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearch< POLICY, FACTORY >::GoUctGlobalSearch(), and GoUctGlobalSearch< POLICY, FACTORY >::OnStartSearch().