Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexUctPolicy Class Reference

Generates moves during the random playout phase of UCT search. More...

#include <HexUctPolicy.hpp>

Inheritance diagram for HexUctPolicy:
HexUctSearchPolicy

List of all members.

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 HexUctSharedPolicym_shared
std::vector< HexPointm_moves
std::vector< HexPointm_response [BLACK_AND_WHITE][BITSETSIZE]
SgRandom m_random
 Generator for this policy.

Static Private Attributes

static const int MAX_VOTES = 1024

Detailed Description

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.


Constructor & Destructor Documentation

HexUctPolicy::HexUctPolicy ( const HexUctSharedPolicy shared  ) 

Constructor.

Creates a policy.

Definition at line 111 of file HexUctPolicy.cpp.

HexUctPolicy::~HexUctPolicy (  ) 

Definition at line 119 of file HexUctPolicy.cpp.


Member Function Documentation

void HexUctPolicy::AddResponse ( HexColor  toPlay,
HexPoint  lastMove,
HexPoint  response 
) [inline]
HexPoint HexUctPolicy::GenerateMove ( PatternState pastate,
HexColor  color,
HexPoint  lastMove 
) [virtual]
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]
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]
Todo:
Pass initialial tree and initialize off of that?

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().


Member Data Documentation

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().

Definition at line 171 of file HexUctPolicy.hpp.

Referenced by AddResponse(), GenerateResponseMove(), and InitializeForSearch().

const int HexUctPolicy::MAX_VOTES = 1024 [static, private]

Definition at line 165 of file HexUctPolicy.hpp.

Referenced by PickRandomPatternMove().


The documentation for this class was generated from the following files:


6 Jan 2011 Doxygen 1.6.3