Generates moves during the random playout phase of UCT search. More...
#include <HexUctPolicy.hpp>
Public Member Functions | |
HexUctPolicy (const HexUctSharedPolicy *shared) | |
Constructor. | |
~HexUctPolicy () | |
HexPoint | GenerateMove (PatternState &pastate, HexColor color, HexPoint lastMove) |
Implementation of SgUctSearch::GenerateRandomMove(). | |
void | InitializeForRollout (const StoneBoard &brd) |
Initializes the moves to generate from the empty cells on the given board. | |
void | InitializeForSearch () |
void | AddResponse (HexColor toPlay, HexPoint lastMove, HexPoint response) |
Private Member Functions | |
HexPoint | PickRandomPatternMove (const PatternState &pastate, const HashedPatternSet &patterns, HexColor toPlay, HexPoint lastMove) |
Randomly picks a pattern move from the set of patterns that hit the last move, weighted by the pattern's weight. | |
HexPoint | GeneratePatternMove (const PatternState &pastate, HexColor color, HexPoint lastMove) |
Uses PickRandomPatternMove() with the shared PlayPatterns(). | |
HexPoint | GenerateResponseMove (HexColor toPlay, HexPoint lastMove, const StoneBoard &brd) |
HexPoint | GenerateRandomMove (const StoneBoard &brd) |
Selects random move among the empty cells on the board. | |
Private Attributes | |
const HexUctSharedPolicy * | m_shared |
std::vector< HexPoint > | m_moves |
std::vector< HexPoint > | m_response [BLACK_AND_WHITE][BITSETSIZE] |
SgRandom | m_random |
Generator for this policy. | |
Static Private Attributes | |
static const int | MAX_VOTES = 1024 |
Generates moves during the random playout phase of UCT search.
Uses local configuration and pattern data in HexUctSharedPolicy. Everything in this class must be thread-safe.
Definition at line 128 of file HexUctPolicy.hpp.
HexUctPolicy::HexUctPolicy | ( | const HexUctSharedPolicy * | shared | ) |
HexUctPolicy::~HexUctPolicy | ( | ) |
Definition at line 119 of file HexUctPolicy.cpp.
Definition at line 196 of file HexUctPolicy.hpp.
References HexUctSharedPolicy::Config(), m_response, m_shared, and HexUctPolicyConfig::responseHeuristic.
Referenced by HexUctState::ExecuteTreeMove().
HexPoint HexUctPolicy::GenerateMove | ( | PatternState & | pastate, | |
HexColor | color, | |||
HexPoint | lastMove | |||
) | [virtual] |
Implementation of SgUctSearch::GenerateRandomMove().
Implements HexUctSearchPolicy.
Definition at line 141 of file HexUctPolicy.cpp.
References PatternState::Board(), HexUctSharedPolicy::Config(), GeneratePatternMove(), GenerateRandomMove(), GenerateResponseMove(), HexAssert, INVALID_POINT, StoneBoard::IsEmpty(), m_random, m_shared, HexUctPolicyConfig::pattern_check_percent, HexUctPolicyStatistics::pattern_moves, HexUctPolicyConfig::patternHeuristic, HexUctPolicyStatistics::random_moves, HexUctPolicyConfig::responseHeuristic, and HexUctPolicyStatistics::total_moves.
HexPoint HexUctPolicy::GeneratePatternMove | ( | const PatternState & | pastate, | |
HexColor | toPlay, | |||
HexPoint | lastMove | |||
) | [private] |
Uses PickRandomPatternMove() with the shared PlayPatterns().
Definition at line 324 of file HexUctPolicy.cpp.
References m_shared, PickRandomPatternMove(), and HexUctSharedPolicy::PlayPatterns().
Referenced by GenerateMove().
HexPoint HexUctPolicy::GenerateRandomMove | ( | const StoneBoard & | brd | ) | [private] |
Selects random move among the empty cells on the board.
Definition at line 257 of file HexUctPolicy.cpp.
References HexAssert, INVALID_POINT, StoneBoard::IsEmpty(), and m_moves.
Referenced by GenerateMove().
HexPoint HexUctPolicy::GenerateResponseMove | ( | HexColor | toPlay, | |
HexPoint | lastMove, | |||
const StoneBoard & | brd | |||
) | [private] |
Definition at line 243 of file HexUctPolicy.cpp.
References HexUctSharedPolicy::Config(), INVALID_POINT, StoneBoard::IsEmpty(), m_random, m_response, m_shared, and HexUctPolicyConfig::response_threshold.
Referenced by GenerateMove().
void HexUctPolicy::InitializeForRollout | ( | const StoneBoard & | brd | ) | [virtual] |
Initializes the moves to generate from the empty cells on the given board.
Should be called with the boardstate before any calls to GenerateMove().
Implements HexUctSearchPolicy.
Definition at line 135 of file HexUctPolicy.cpp.
References BitsetUtil::BitsetToVector(), StoneBoard::GetEmpty(), m_moves, and m_random.
void HexUctPolicy::InitializeForSearch | ( | ) | [virtual] |
Implements HexUctSearchPolicy.
Definition at line 126 of file HexUctPolicy.cpp.
References BITSETSIZE, BLACK, m_response, and WHITE.
HexPoint HexUctPolicy::PickRandomPatternMove | ( | const PatternState & | pastate, | |
const HashedPatternSet & | patterns, | |||
HexColor | toPlay, | |||
HexPoint | lastMove | |||
) | [private] |
Randomly picks a pattern move from the set of patterns that hit the last move, weighted by the pattern's weight.
If no pattern matches, returns INVALID_POINT.
Definition at line 274 of file HexUctPolicy.cpp.
References HexAssert, INVALID_POINT, m_random, m_shared, PatternState::MATCH_ALL, PatternState::MatchOnCell(), MAX_VOTES, and UNUSED().
Referenced by GeneratePatternMove().
std::vector<HexPoint> HexUctPolicy::m_moves [private] |
Definition at line 169 of file HexUctPolicy.hpp.
Referenced by GenerateRandomMove(), and InitializeForRollout().
SgRandom HexUctPolicy::m_random [private] |
Generator for this policy.
Definition at line 174 of file HexUctPolicy.hpp.
Referenced by GenerateMove(), GenerateResponseMove(), InitializeForRollout(), and PickRandomPatternMove().
std::vector<HexPoint> HexUctPolicy::m_response[BLACK_AND_WHITE][BITSETSIZE] [private] |
Definition at line 171 of file HexUctPolicy.hpp.
Referenced by AddResponse(), GenerateResponseMove(), and InitializeForSearch().
const HexUctSharedPolicy* HexUctPolicy::m_shared [private] |
Definition at line 167 of file HexUctPolicy.hpp.
Referenced by AddResponse(), GenerateMove(), GeneratePatternMove(), GenerateResponseMove(), and PickRandomPatternMove().
const int HexUctPolicy::MAX_VOTES = 1024 [static, private] |
Definition at line 165 of file HexUctPolicy.hpp.
Referenced by PickRandomPatternMove().