Thread state for HexUctSearch. More...
#include <HexUctState.hpp>
Classes | |
class | AssertionHandler |
Assertion handler to dump the state of a HexUctState. More... | |
Public Member Functions | |
HexUctState (const unsigned int threadId, HexUctSearch &sch, int treeUpdateRadius, int playoutUpdateRadius) | |
Constructor. | |
virtual | ~HexUctState () |
const StoneBoard & | Board () const |
const PatternState & | GetPatternState () const |
HexUctSearchPolicy * | Policy () |
bool | IsInPlayout () const |
std::string | Dump () const |
void | SetPolicy (HexUctSearchPolicy *policy) |
Sets policy (takes control of pointer) and deletes the old one, if it existed. | |
HexPoint | GetLastMovePlayed () const |
HexColor | GetColorToPlay () const |
Pure virtual functions of SgUctThreadState | |
SgUctValue | Evaluate () |
void | Execute (SgMove move) |
void | ExecutePlayout (SgMove move) |
bool | GenerateAllMoves (SgUctValue count, std::vector< SgMoveInfo > &moves, SgProvenNodeType &provenType) |
SgMove | GeneratePlayoutMove (bool &skipRaveUpdate) |
void | StartSearch () |
void | TakeBackInTree (std::size_t nuMoves) |
void | TakeBackPlayout (std::size_t nuMoves) |
SgBlackWhite | ToPlay () const |
Virtual functions of SgUctThreadState | |
void | GameStart () |
void | StartPlayouts () |
virtual void | StartPlayout () |
virtual void | EndPlayout () |
Private Member Functions | |
bitset_t | ComputeKnowledge (SgProvenNodeType &provenType) |
Computes moves to consider and stores fillin in the shared data. | |
void | ExecuteTreeMove (HexPoint move) |
void | ExecuteRolloutMove (HexPoint move) |
void | ExecutePlainMove (HexPoint cell, int updateRadius) |
Private Attributes | |
AssertionHandler | m_assertionHandler |
boost::scoped_ptr< StoneBoard > | m_bd |
boost::scoped_ptr< PatternState > | m_pastate |
Board used during search. | |
boost::scoped_ptr< HexBoard > | m_vc_brd |
Board used to compute knowledge. | |
boost::scoped_ptr < HexUctSearchPolicy > | m_policy |
Playout policy. | |
HexUctSharedData * | m_shared_data |
Data shared between threads. | |
HexUctKnowledge | m_knowledge |
HexUctSearch & | m_search |
Parent search object. | |
HexColor | m_toPlay |
Color to play next. | |
int | m_treeUpdateRadius |
See HexUctSearch::TreeUpdateRadius(). | |
int | m_playoutUpdateRadius |
See HexUctSearch::PlayoutUpdateRadius(). | |
bool | m_isInPlayout |
True if in playout phase. | |
MoveSequence | m_game_sequence |
Moves played the game plus moves in tree. | |
HexPoint | m_lastMovePlayed |
Keeps track of last playout move made. | |
bool | m_new_game |
True at the start of a game until the first move is played. |
Thread state for HexUctSearch.
Definition at line 127 of file HexUctState.hpp.
HexUctState::HexUctState | ( | const unsigned int | threadId, | |
HexUctSearch & | sch, | |||
int | treeUpdateRadius, | |||
int | playoutUpdateRadius | |||
) |
Constructor.
threadId | The number of the thread. Needed for passing to constructor of SgUctThreadState. | |
sch | Parent Search object. | |
treeUpdateRadius | Pattern matching radius in tree. | |
playoutUpdateRadius | Pattern matching radius in playouts. |
Definition at line 88 of file HexUctState.cpp.
HexUctState::~HexUctState | ( | ) | [virtual] |
Definition at line 107 of file HexUctState.cpp.
const StoneBoard & HexUctState::Board | ( | ) | const [inline] |
Definition at line 273 of file HexUctState.hpp.
References m_bd.
bitset_t HexUctState::ComputeKnowledge | ( | SgProvenNodeType & | provenType | ) | [private] |
Computes moves to consider and stores fillin in the shared data.
Definition at line 338 of file HexUctState.cpp.
References BLACK, DEBUG_KNOWLEDGE, SequenceHash::Hash(), EndgameUtils::IsDeterminedState(), EndgameUtils::IsLostGame(), LogInfo(), m_bd, m_game_sequence, m_shared_data, m_toPlay, m_vc_brd, EndgameUtils::MovesToConsider(), HashMap< T >::put(), HexUctSharedData::stones, and WHITE.
Referenced by GenerateAllMoves().
std::string HexUctState::Dump | ( | ) | const |
Definition at line 116 of file HexUctState.cpp.
References m_bd, and m_isInPlayout.
Referenced by HexUctState::AssertionHandler::Run().
void HexUctState::EndPlayout | ( | ) | [virtual] |
Definition at line 332 of file HexUctState.cpp.
SgUctValue HexUctState::Evaluate | ( | ) |
Definition at line 126 of file HexUctState.cpp.
void HexUctState::Execute | ( | SgMove | move | ) |
Definition at line 133 of file HexUctState.cpp.
References ExecuteTreeMove(), and m_toPlay.
void HexUctState::ExecutePlainMove | ( | HexPoint | cell, | |
int | updateRadius | |||
) | [private] |
Definition at line 172 of file HexUctState.cpp.
References m_bd, m_lastMovePlayed, m_new_game, m_pastate, and m_toPlay.
Referenced by ExecuteRolloutMove(), and ExecuteTreeMove().
void HexUctState::ExecutePlayout | ( | SgMove | move | ) |
Definition at line 139 of file HexUctState.cpp.
References ExecuteRolloutMove(), and m_toPlay.
void HexUctState::ExecuteRolloutMove | ( | HexPoint | move | ) | [private] |
Definition at line 167 of file HexUctState.cpp.
References ExecutePlainMove(), and m_playoutUpdateRadius.
Referenced by ExecutePlayout().
void HexUctState::ExecuteTreeMove | ( | HexPoint | move | ) | [private] |
Definition at line 145 of file HexUctState.cpp.
References HexUctPolicy::AddResponse(), HexUctStoneData::black, BLACK, ExecutePlainMove(), HashMap< T >::get(), SequenceHash::Hash(), m_bd, m_game_sequence, m_lastMovePlayed, m_pastate, m_policy, m_shared_data, m_toPlay, m_treeUpdateRadius, HexUctStoneData::played, HexUctSharedData::stones, HexUctStoneData::white, and WHITE.
Referenced by Execute().
void HexUctState::GameStart | ( | ) |
Definition at line 298 of file HexUctState.cpp.
References HexUctStoneData::black, BLACK, HexUctSharedData::game_sequence, m_bd, m_game_sequence, m_isInPlayout, m_lastMovePlayed, m_new_game, m_pastate, m_shared_data, m_toPlay, m_treeUpdateRadius, HexUctStoneData::played, HexUctSharedData::root_last_move_played, HexUctSharedData::root_stones, HexUctSharedData::root_to_play, HexUctStoneData::white, and WHITE.
bool HexUctState::GenerateAllMoves | ( | SgUctValue | count, | |
std::vector< SgMoveInfo > & | moves, | |||
SgProvenNodeType & | provenType | |||
) |
Definition at line 198 of file HexUctState.cpp.
References ComputeKnowledge(), EMPTY, SequenceHash::Hash(), hash_t, LogInfo(), m_bd, m_game_sequence, m_knowledge, m_new_game, m_shared_data, m_toPlay, HexUctKnowledge::ProcessPosition(), HexUctSharedData::root_consider, HexColorUtil::toString(), and TRACK_KNOWLEDGE.
SgMove HexUctState::GeneratePlayoutMove | ( | bool & | skipRaveUpdate | ) |
Definition at line 247 of file HexUctState.cpp.
References m_bd, m_lastMovePlayed, m_pastate, m_policy, and m_toPlay.
HexColor HexUctState::GetColorToPlay | ( | ) | const [inline] |
Definition at line 298 of file HexUctState.hpp.
References m_toPlay.
HexPoint HexUctState::GetLastMovePlayed | ( | ) | const [inline] |
Definition at line 293 of file HexUctState.hpp.
References m_lastMovePlayed.
const PatternState & HexUctState::GetPatternState | ( | ) | const [inline] |
Definition at line 278 of file HexUctState.hpp.
References m_pastate.
bool HexUctState::IsInPlayout | ( | ) | const [inline] |
Definition at line 288 of file HexUctState.hpp.
References m_isInPlayout.
HexUctSearchPolicy * HexUctState::Policy | ( | ) | [inline] |
Definition at line 283 of file HexUctState.hpp.
References m_policy.
void HexUctState::SetPolicy | ( | HexUctSearchPolicy * | policy | ) |
Sets policy (takes control of pointer) and deletes the old one, if it existed.
Definition at line 111 of file HexUctState.cpp.
References m_policy.
Referenced by HexThreadStateFactory::Create().
void HexUctState::StartPlayout | ( | ) | [virtual] |
Definition at line 327 of file HexUctState.cpp.
void HexUctState::StartPlayouts | ( | ) |
Playout radius should normally be no bigger than tree radius, but if it is, we need to do an extra update for each playout during the transition from the tree phase to the playout phase.
Definition at line 314 of file HexUctState.cpp.
References m_isInPlayout, m_pastate, m_playoutUpdateRadius, and m_treeUpdateRadius.
void HexUctState::StartSearch | ( | ) |
Definition at line 260 of file HexUctState.cpp.
References HexUctSearch::Board(), HexBoard::Builder(), HexBoard::Height(), HexBoard::ICE(), LogInfo(), m_bd, m_pastate, m_policy, m_search, m_shared_data, m_vc_brd, VCBuilder::Parameters(), HexUctSearch::SharedData(), and HexBoard::Width().
void HexUctState::TakeBackInTree | ( | std::size_t | nuMoves | ) |
Definition at line 283 of file HexUctState.cpp.
void HexUctState::TakeBackPlayout | ( | std::size_t | nuMoves | ) |
Definition at line 288 of file HexUctState.cpp.
SgBlackWhite HexUctState::ToPlay | ( | ) | const |
Definition at line 293 of file HexUctState.cpp.
References m_toPlay, and HexUctUtil::ToSgBlackWhite().
Definition at line 218 of file HexUctState.hpp.
boost::scoped_ptr<StoneBoard> HexUctState::m_bd [private] |
Definition at line 220 of file HexUctState.hpp.
Referenced by Board(), ComputeKnowledge(), Dump(), Evaluate(), ExecutePlainMove(), ExecuteTreeMove(), GameStart(), GenerateAllMoves(), GeneratePlayoutMove(), StartPlayout(), and StartSearch().
MoveSequence HexUctState::m_game_sequence [private] |
Moves played the game plus moves in tree.
Definition at line 252 of file HexUctState.hpp.
Referenced by ComputeKnowledge(), ExecuteTreeMove(), GameStart(), and GenerateAllMoves().
bool HexUctState::m_isInPlayout [private] |
True if in playout phase.
Definition at line 249 of file HexUctState.hpp.
Referenced by Dump(), GameStart(), IsInPlayout(), and StartPlayouts().
HexUctKnowledge HexUctState::m_knowledge [private] |
Definition at line 234 of file HexUctState.hpp.
Referenced by GenerateAllMoves().
HexPoint HexUctState::m_lastMovePlayed [private] |
Keeps track of last playout move made.
Used for pattern-generated rollouts when call HexUctSearchPolicy.
Definition at line 257 of file HexUctState.hpp.
Referenced by ExecutePlainMove(), ExecuteTreeMove(), GameStart(), GeneratePlayoutMove(), and GetLastMovePlayed().
bool HexUctState::m_new_game [private] |
True at the start of a game until the first move is played.
Definition at line 260 of file HexUctState.hpp.
Referenced by ExecutePlainMove(), GameStart(), and GenerateAllMoves().
boost::scoped_ptr<PatternState> HexUctState::m_pastate [private] |
Board used during search.
Definition at line 223 of file HexUctState.hpp.
Referenced by ExecutePlainMove(), ExecuteTreeMove(), GameStart(), GeneratePlayoutMove(), GetPatternState(), StartPlayouts(), and StartSearch().
int HexUctState::m_playoutUpdateRadius [private] |
See HexUctSearch::PlayoutUpdateRadius().
Definition at line 246 of file HexUctState.hpp.
Referenced by ExecuteRolloutMove(), and StartPlayouts().
boost::scoped_ptr<HexUctSearchPolicy> HexUctState::m_policy [private] |
Playout policy.
Definition at line 229 of file HexUctState.hpp.
Referenced by ExecuteTreeMove(), GeneratePlayoutMove(), Policy(), SetPolicy(), StartPlayout(), and StartSearch().
HexUctSearch& HexUctState::m_search [private] |
HexUctSharedData* HexUctState::m_shared_data [private] |
Data shared between threads.
Definition at line 232 of file HexUctState.hpp.
Referenced by ComputeKnowledge(), ExecuteTreeMove(), GameStart(), GenerateAllMoves(), and StartSearch().
HexColor HexUctState::m_toPlay [private] |
Color to play next.
Definition at line 240 of file HexUctState.hpp.
Referenced by ComputeKnowledge(), Evaluate(), Execute(), ExecutePlainMove(), ExecutePlayout(), ExecuteTreeMove(), GameStart(), GenerateAllMoves(), GeneratePlayoutMove(), GetColorToPlay(), and ToPlay().
int HexUctState::m_treeUpdateRadius [private] |
See HexUctSearch::TreeUpdateRadius().
Definition at line 243 of file HexUctState.hpp.
Referenced by ExecuteTreeMove(), GameStart(), and StartPlayouts().
boost::scoped_ptr<HexBoard> HexUctState::m_vc_brd [private] |
Board used to compute knowledge.
Definition at line 226 of file HexUctState.hpp.
Referenced by ComputeKnowledge(), and StartSearch().