#include <GoUctGlobalSearch.h>
Inheritance diagram for GoUctGlobalSearchState< POLICY >:
Definition at line 105 of file GoUctGlobalSearch.h.
Public Member Functions | |
GoUctGlobalSearchState (std::size_t threadId, const GoBoard &bd, POLICY *policy, const GoUctGlobalSearchStateParam ¶m, const GoUctPlayoutPolicyParam &policyParam, const SgBWSet &safe, const SgPointArray< bool > &allSafe) | |
Constructor. | |
~GoUctGlobalSearchState () | |
float | Evaluate () |
bool | GenerateAllMoves (std::size_t count, std::vector< SgMoveInfo > &moves, SgProvenNodeType &provenType) |
SgMove | GeneratePlayoutMove (bool &skipRaveUpdate) |
void | ExecutePlayout (SgMove move) |
Implementation of SgUctSearch::ExecutePlayout. | |
void | GameStart () |
void | EndPlayout () |
void | StartPlayout () |
void | StartPlayouts () |
void | StartSearch () |
POLICY * | Policy () |
void | SetPolicy (POLICY *policy) |
Set random policy. | |
void | ClearTerritoryStatistics () |
const GoBoard & | Board () const |
Board used during in-tree phase. | |
const GoUctBoard & | UctBoard () const |
Board used during playout phase. | |
bool | IsInPlayout () const |
int | GameLength () const |
Length of the current game from the root position of the search. | |
void | Dump (std::ostream &out) const |
Pure virtual functions of SgUctThreadState | |
void | Execute (SgMove move) |
Implementation of SgUctSearch::Execute. | |
void | TakeBackInTree (std::size_t nuMoves) |
void | TakeBackPlayout (std::size_t nuMoves) |
Public Attributes | |
const SgBWSet & | m_safe |
const SgPointArray< bool > & | m_allSafe |
SgPointArray< SgUctStatistics > | m_territoryStatistics |
Probabilities that a point belongs to Black in a terminal position. | |
const std::size_t | m_threadId |
bool | m_isSearchInitialized |
bool | m_isTreeOutOfMem |
SgUctGameInfo | m_gameInfo |
boost::scoped_array< std::size_t > | m_firstPlay |
boost::scoped_array< std::size_t > | m_firstPlayOpp |
std::vector< SgMoveInfo > | m_moves |
std::vector< SgMove > | m_excludeMoves |
int | m_randomizeCounter |
Private Member Functions | |
GoUctGlobalSearchState (const GoUctGlobalSearchState &search) | |
Not implemented. | |
GoUctGlobalSearchState & | operator= (const GoUctGlobalSearchState &search) |
Not implemented. | |
bool | CheckMercyRule () |
See SetMercyRule(). | |
template<class BOARD> | |
float | EvaluateBoard (const BOARD &bd, float komi) |
void | GenerateLegalMoves (std::vector< SgMoveInfo > &moves) |
Generates all legal moves with no knowledge values. | |
float | GetKomi () const |
Get komi including extra handicap komi points, if used by the rules. | |
Private Attributes | |
const GoUctGlobalSearchStateParam & | m_param |
const GoUctPlayoutPolicyParam & | m_policyParam |
bool | m_mercyRuleTriggered |
See SetMercyRule(). | |
int | m_passMovesPlayoutPhase |
Number of pass moves played in a row in the playout phase. | |
int | m_mercyRuleThreshold |
See SetMercyRule(). | |
int | m_stoneDiff |
Difference of stones on board. | |
int | m_initialMoveNumber |
Board move number at root node of search. | |
GoPointList | m_area |
The area in which moves should be generated. | |
float | m_mercyRuleResult |
See SetMercyRule(). | |
float | m_invMaxScore |
Inverse of maximum score one can reach on a board of the current size. | |
SgRandom | m_random |
GoUctDefaultPriorKnowledge | m_priorKnowledge |
boost::scoped_ptr< POLICY > | m_policy |
GoUctGlobalSearchState< POLICY >::GoUctGlobalSearchState | ( | std::size_t | threadId, | |
const GoBoard & | bd, | |||
POLICY * | policy, | |||
const GoUctGlobalSearchStateParam & | param, | |||
const GoUctPlayoutPolicyParam & | policyParam, | |||
const SgBWSet & | safe, | |||
const SgPointArray< bool > & | allSafe | |||
) |
Constructor.
threadId | The number of the thread. Needed for passing to constructor of SgUctThreadState. | |
bd | The board | |
policy | The random policy (takes ownership). It is possible to set the policy to null at construction time to allowed a multi-step construction; but then a policy has to be set with SetPolicy(), before the search is used. | |
param | Parameters. Stores a reference to the argument. | |
policy_param. | Stores a reference to the argument. | |
safe | Safety information. Stores a reference to the argument. | |
allSafe | Safety information. Stores a reference to the argument. |
Definition at line 225 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::ClearTerritoryStatistics().
GoUctGlobalSearchState< POLICY >::~GoUctGlobalSearchState | ( | ) |
Definition at line 242 of file GoUctGlobalSearch.h.
GoUctGlobalSearchState< POLICY >::GoUctGlobalSearchState | ( | const GoUctGlobalSearchState< POLICY > & | search | ) | [private] |
Not implemented.
const GoBoard & GoUctState::Board | ( | ) | const [inherited] |
Board used during in-tree phase.
Definition at line 109 of file GoUctSearch.h.
References GoUctState::m_bd.
Referenced by GoUctGlobalSearchState< POLICY >::Evaluate(), GoUctGlobalSearchState< POLICY >::GenerateLegalMoves(), GoUctGlobalSearchState< POLICY >::GetKomi(), GoUctGlobalSearchState< POLICY >::StartPlayout(), and GoUctGlobalSearchState< POLICY >::StartSearch().
bool GoUctGlobalSearchState< POLICY >::CheckMercyRule | ( | ) | [private] |
See SetMercyRule().
Definition at line 248 of file GoUctGlobalSearch.h.
References GoUctState::IsInPlayout(), GoUctGlobalSearchStateParam::m_mercyRule, GoUctGlobalSearchState< POLICY >::m_mercyRuleResult, GoUctGlobalSearchState< POLICY >::m_mercyRuleThreshold, GoUctGlobalSearchState< POLICY >::m_mercyRuleTriggered, GoUctGlobalSearchState< POLICY >::m_param, GoUctGlobalSearchState< POLICY >::m_stoneDiff, SG_ASSERT, SG_BLACK, SG_WHITE, GoUctBoard::ToPlay(), and GoUctState::UctBoard().
Referenced by GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove().
void GoUctGlobalSearchState< POLICY >::ClearTerritoryStatistics | ( | ) |
Definition at line 269 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::m_territoryStatistics.
Referenced by GoUctGlobalSearchState< POLICY >::GoUctGlobalSearchState(), and GoUctGlobalSearchState< POLICY >::StartSearch().
void GoUctState::Dump | ( | std::ostream & | out | ) | const [inherited] |
Definition at line 109 of file GoUctSearch.cpp.
References GoUctState::m_bd, GoUctState::m_isInPlayout, SgUctThreadState::m_threadId, and GoUctState::m_uctBd.
Referenced by GoUctState::AssertionHandler::Run().
void GoUctGlobalSearchState< POLICY >::EndPlayout | ( | ) | [virtual] |
Reimplemented from SgUctThreadState.
Definition at line 277 of file GoUctGlobalSearch.h.
References SgUctThreadState::EndPlayout(), and GoUctGlobalSearchState< POLICY >::m_policy.
float GoUctGlobalSearchState< POLICY >::Evaluate | ( | ) | [virtual] |
Implements SgUctThreadState.
Definition at line 284 of file GoUctGlobalSearch.h.
References GoUctState::Board(), GoUctGlobalSearchState< POLICY >::EvaluateBoard(), GoUctGlobalSearchState< POLICY >::GetKomi(), GoUctState::IsInPlayout(), and GoUctState::UctBoard().
float GoUctGlobalSearchState< POLICY >::EvaluateBoard | ( | const BOARD & | bd, | |
float | komi | |||
) | [private] |
Definition at line 295 of file GoUctGlobalSearch.h.
References GoUctState::GameLength(), GoUctGlobalSearchState< POLICY >::m_invMaxScore, GoUctGlobalSearchStateParam::m_lengthModification, GoUctGlobalSearchStateParam::m_mercyRule, GoUctGlobalSearchState< POLICY >::m_mercyRuleResult, GoUctGlobalSearchState< POLICY >::m_mercyRuleTriggered, GoUctGlobalSearchState< POLICY >::m_param, GoUctGlobalSearchState< POLICY >::m_passMovesPlayoutPhase, GoUctGlobalSearchState< POLICY >::m_safe, GoUctGlobalSearchStateParam::m_scoreModification, GoUctGlobalSearchState< POLICY >::m_territoryStatistics, GoUctGlobalSearchStateParam::m_territoryStatistics, GoBoardUtil::ScoreSimpleEndPosition(), SG_BLACK, SG_EMPTY, SG_WHITE, and GoBoardUtil::TrompTaylorScore().
Referenced by GoUctGlobalSearchState< POLICY >::Evaluate().
void GoUctState::Execute | ( | SgMove | move | ) | [virtual, inherited] |
Implementation of SgUctSearch::Execute.
Implements SgUctThreadState.
Definition at line 118 of file GoUctSearch.cpp.
References GO_MOVEFLAG_ILLEGAL, GoUctState::m_bd, GoUctState::m_gameLength, GoUctState::m_isInPlayout, GoBoard::Occupied(), SG_ASSERT, SG_PASS, and GoRules::SIMPLEKO.
void GoUctGlobalSearchState< POLICY >::ExecutePlayout | ( | SgMove | move | ) | [virtual] |
Implementation of SgUctSearch::ExecutePlayout.
Reimplemented from GoUctState.
Definition at line 348 of file GoUctGlobalSearch.h.
References GoUctState::ExecutePlayout(), GoUctGlobalSearchState< POLICY >::m_policy, GoUctGlobalSearchState< POLICY >::m_stoneDiff, GoUctBoard::NuCapturedStones(), SG_BLACK, GoUctBoard::ToPlay(), and GoUctState::UctBoard().
int GoUctState::GameLength | ( | ) | const [inherited] |
Length of the current game from the root position of the search.
Definition at line 114 of file GoUctSearch.h.
References GoUctState::m_gameLength.
Referenced by GoUctGlobalSearchState< POLICY >::EvaluateBoard().
void GoUctGlobalSearchState< POLICY >::GameStart | ( | ) | [virtual] |
Reimplemented from GoUctState.
Definition at line 360 of file GoUctGlobalSearch.h.
References GoUctState::GameStart().
bool GoUctGlobalSearchState< POLICY >::GenerateAllMoves | ( | std::size_t | count, | |
std::vector< SgMoveInfo > & | moves, | |||
SgProvenNodeType & | provenType | |||
) | [virtual] |
Implements SgUctThreadState.
Definition at line 409 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::GenerateLegalMoves(), GoUctGlobalSearchState< POLICY >::m_priorKnowledge, GoUctDefaultPriorKnowledge::ProcessPosition(), and SG_NOT_PROVEN.
Referenced by GoUctCommands::CmdPriorKnowledge().
void GoUctGlobalSearchState< POLICY >::GenerateLegalMoves | ( | std::vector< SgMoveInfo > & | moves | ) | [private] |
Generates all legal moves with no knowledge values.
Definition at line 366 of file GoUctGlobalSearch.h.
References GoRules::AllowSuicide(), GoUctState::Board(), SgRandom::Int(), GoEyeUtil::IsSimpleEye(), GoUctGlobalSearchState< POLICY >::m_allSafe, GoUctGlobalSearchState< POLICY >::m_initialMoveNumber, GoUctGlobalSearchState< POLICY >::m_random, GoBoard::Rules(), SG_ASSERT, SG_PASS, and GoBoardUtil::TwoPasses().
Referenced by GoUctGlobalSearchState< POLICY >::GenerateAllMoves().
SgMove GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove | ( | bool & | skipRaveUpdate | ) | [virtual] |
Implements SgUctThreadState.
Definition at line 425 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctUtil::GeneratePoint(), GoUctState::IsInPlayout(), GoUctGlobalSearchStateParam::m_mercyRule, GoUctGlobalSearchState< POLICY >::m_param, GoUctGlobalSearchState< POLICY >::m_passMovesPlayoutPhase, GoUctGlobalSearchState< POLICY >::m_policy, GoUctGlobalSearchState< POLICY >::m_safe, SgBWSet::OneContains(), GoBoardUtil::SelfAtari(), SG_ASSERT, SG_NULLMOVE, SG_PASS, and GoUctState::UctBoard().
float GoUctGlobalSearchState< POLICY >::GetKomi | ( | ) | const [private] |
Get komi including extra handicap komi points, if used by the rules.
Definition at line 470 of file GoUctGlobalSearch.h.
References GoUctState::Board(), GoRules::ExtraHandicapKomi(), GoRules::Handicap(), GoRules::Komi(), GoBoard::Rules(), and GoKomi::ToFloat().
Referenced by GoUctGlobalSearchState< POLICY >::Evaluate(), and GoUctGlobalSearchState< POLICY >::StartSearch().
bool GoUctState::IsInPlayout | ( | ) | const [inherited] |
Definition at line 119 of file GoUctSearch.h.
References GoUctState::m_isInPlayout.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::Evaluate(), and GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove().
GoUctGlobalSearchState& GoUctGlobalSearchState< POLICY >::operator= | ( | const GoUctGlobalSearchState< POLICY > & | search | ) | [private] |
Not implemented.
POLICY * GoUctGlobalSearchState< POLICY >::Policy | ( | ) |
Definition at line 480 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::m_policy.
void GoUctGlobalSearchState< POLICY >::SetPolicy | ( | POLICY * | policy | ) |
Set random policy.
Sets a new random policy and deletes the old one, if it existed.
Definition at line 486 of file GoUctGlobalSearch.h.
References GoUctGlobalSearchState< POLICY >::m_policy.
void GoUctGlobalSearchState< POLICY >::StartPlayout | ( | ) | [virtual] |
Reimplemented from GoUctState.
Definition at line 492 of file GoUctGlobalSearch.h.
References GoBoard::All(), GoUctState::Board(), GoUctGlobalSearchState< POLICY >::m_mercyRuleTriggered, GoUctGlobalSearchState< POLICY >::m_passMovesPlayoutPhase, GoUctGlobalSearchState< POLICY >::m_policy, GoUctGlobalSearchState< POLICY >::m_stoneDiff, SG_BLACK, SG_WHITE, SgPointSet::Size(), and GoUctState::StartPlayout().
void GoUctGlobalSearchState< POLICY >::StartPlayouts | ( | ) | [virtual] |
Reimplemented from GoUctState.
Definition at line 503 of file GoUctGlobalSearch.h.
References GoUctState::StartPlayouts().
void GoUctGlobalSearchState< POLICY >::StartSearch | ( | ) | [virtual] |
Reimplemented from GoUctState.
Definition at line 509 of file GoUctGlobalSearch.h.
References GoUctState::Board(), GoUctGlobalSearchState< POLICY >::ClearTerritoryStatistics(), GoUctGlobalSearchState< POLICY >::GetKomi(), GoUctGlobalSearchState< POLICY >::m_initialMoveNumber, GoUctGlobalSearchState< POLICY >::m_invMaxScore, GoUctGlobalSearchState< POLICY >::m_mercyRuleThreshold, GoBoard::MoveNumber(), GoBoard::Size(), and GoUctState::StartSearch().
Referenced by GoUctCommands::CmdPriorKnowledge().
void GoUctState::TakeBackInTree | ( | std::size_t | nuMoves | ) | [virtual, inherited] |
Implements SgUctThreadState.
Definition at line 160 of file GoUctSearch.cpp.
References GoUctState::m_bd, and GoBoard::Undo().
void GoUctState::TakeBackPlayout | ( | std::size_t | nuMoves | ) | [virtual, inherited] |
Implements SgUctThreadState.
Definition at line 166 of file GoUctSearch.cpp.
References GoUctState::m_gameLength.
const GoUctBoard & GoUctState::UctBoard | ( | ) | const [inherited] |
Board used during playout phase.
Definition at line 124 of file GoUctSearch.h.
References GoUctState::m_uctBd.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::Evaluate(), GoUctGlobalSearchState< POLICY >::ExecutePlayout(), and GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove().
const SgPointArray<bool>& GoUctGlobalSearchState< POLICY >::m_allSafe |
Definition at line 111 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::GenerateLegalMoves().
GoPointList GoUctGlobalSearchState< POLICY >::m_area [private] |
int GoUctGlobalSearchState< POLICY >::m_initialMoveNumber [private] |
Board move number at root node of search.
Definition at line 188 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::GenerateLegalMoves(), and GoUctGlobalSearchState< POLICY >::StartSearch().
float GoUctGlobalSearchState< POLICY >::m_invMaxScore [private] |
Inverse of maximum score one can reach on a board of the current size.
Definition at line 199 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::EvaluateBoard(), and GoUctGlobalSearchState< POLICY >::StartSearch().
float GoUctGlobalSearchState< POLICY >::m_mercyRuleResult [private] |
See SetMercyRule().
Definition at line 194 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), and GoUctGlobalSearchState< POLICY >::EvaluateBoard().
int GoUctGlobalSearchState< POLICY >::m_mercyRuleThreshold [private] |
See SetMercyRule().
Definition at line 180 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), and GoUctGlobalSearchState< POLICY >::StartSearch().
bool GoUctGlobalSearchState< POLICY >::m_mercyRuleTriggered [private] |
See SetMercyRule().
Definition at line 174 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::EvaluateBoard(), and GoUctGlobalSearchState< POLICY >::StartPlayout().
const GoUctGlobalSearchStateParam& GoUctGlobalSearchState< POLICY >::m_param [private] |
Definition at line 169 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::EvaluateBoard(), and GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove().
int GoUctGlobalSearchState< POLICY >::m_passMovesPlayoutPhase [private] |
Number of pass moves played in a row in the playout phase.
Definition at line 177 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::EvaluateBoard(), GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove(), and GoUctGlobalSearchState< POLICY >::StartPlayout().
boost::scoped_ptr<POLICY> GoUctGlobalSearchState< POLICY >::m_policy [private] |
Definition at line 205 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::EndPlayout(), GoUctGlobalSearchState< POLICY >::ExecutePlayout(), GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove(), GoUctGlobalSearchState< POLICY >::Policy(), GoUctGlobalSearchState< POLICY >::SetPolicy(), and GoUctGlobalSearchState< POLICY >::StartPlayout().
const GoUctPlayoutPolicyParam& GoUctGlobalSearchState< POLICY >::m_policyParam [private] |
Definition at line 171 of file GoUctGlobalSearch.h.
GoUctDefaultPriorKnowledge GoUctGlobalSearchState< POLICY >::m_priorKnowledge [private] |
Definition at line 203 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::GenerateAllMoves().
SgRandom GoUctGlobalSearchState< POLICY >::m_random [private] |
Definition at line 201 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::GenerateLegalMoves().
const SgBWSet& GoUctGlobalSearchState< POLICY >::m_safe |
Definition at line 109 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::EvaluateBoard(), and GoUctGlobalSearchState< POLICY >::GeneratePlayoutMove().
int GoUctGlobalSearchState< POLICY >::m_stoneDiff [private] |
Difference of stones on board.
Black counts positive.
Definition at line 185 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::CheckMercyRule(), GoUctGlobalSearchState< POLICY >::ExecutePlayout(), and GoUctGlobalSearchState< POLICY >::StartPlayout().
SgPointArray<SgUctStatistics> GoUctGlobalSearchState< POLICY >::m_territoryStatistics |
Probabilities that a point belongs to Black in a terminal position.
Only computed if GoUctGlobalSearchStateParam::m_territoryStatistics.
Definition at line 116 of file GoUctGlobalSearch.h.
Referenced by GoUctGlobalSearchState< POLICY >::ClearTerritoryStatistics(), GoUctGlobalSearchState< POLICY >::EvaluateBoard(), and GoUctGlobalSearch< POLICY, FACTORY >::OnSearchIteration().