Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoUctPureRandomGenerator< BOARD > Class Template Reference

#include <GoUctPureRandomGenerator.h>

List of all members.


Detailed Description

template<class BOARD>
class GoUctPureRandomGenerator< BOARD >

Randomly select from empty points on the board.

Finds and shuffles the empty points on the board at the beginning to avoid repeated loops over the board to find empty points.

Definition at line 20 of file GoUctPureRandomGenerator.h.

Public Member Functions

 GoUctPureRandomGenerator (const BOARD &bd, SgRandom &random)
void Start ()
 Finds and shuffles the empty points currently on the board.
void OnPlay ()
 Update state.
const std::vector< SgPoint > & Candidates () const
 Return a list of points that are currently potentially empty.
SgPoint Generate (SgBalancer &balancer)
 Generate a pure random move.
SgPoint GenerateFillboardMove (int numberTries)
 Generate a move using the fillboard heuristic.

Private Member Functions

bool Empty3x3 (SgPoint p) const
void CheckConsistency () const
void Insert (SgPoint p)
 Insert new candidate at random place.

Private Attributes

const BOARD & m_bd
float m_invNuPoints
float m_nuEmptyFloat
SgRandomm_random
std::vector< SgPointm_candidates
 Points that are potentially empty.


Constructor & Destructor Documentation

template<class BOARD>
GoUctPureRandomGenerator< BOARD >::GoUctPureRandomGenerator ( const BOARD &  bd,
SgRandom random 
)

Definition at line 83 of file GoUctPureRandomGenerator.h.

References GO_MAX_NUM_MOVES, and GoUctPureRandomGenerator< BOARD >::m_candidates.


Member Function Documentation

template<class BOARD>
const std::vector< SgPoint > & GoUctPureRandomGenerator< BOARD >::Candidates (  )  const

Return a list of points that are currently potentially empty.

As a side-benefit, the generator can be used to get the list of empty points on the board to speed up full-board loops over empty points or to get a shuffled list of the empty points (e.g. for finding legal moves when expanding a node in the in-tree-phase of UCT). Points in the list are candidates, they still have to be tested, if they are really empty.

Definition at line 93 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::m_candidates.

template<class BOARD>
void GoUctPureRandomGenerator< BOARD >::CheckConsistency (  )  const [private]

Definition at line 100 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, SG_ASSERT, and SgDebug().

Referenced by GoUctPureRandomGenerator< BOARD >::Generate(), GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
bool GoUctPureRandomGenerator< BOARD >::Empty3x3 ( SgPoint  p  )  const [private]

Definition at line 125 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::m_bd.

Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove().

template<class BOARD>
SgPoint GoUctPureRandomGenerator< BOARD >::Generate ( SgBalancer balancer  ) 

Generate a pure random move.

Randomly select an empty point on the board that fulfills GoUctUtil::GeneratePoint() for the color currently to play on the board.

Definition at line 133 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctUtil::GeneratePoint(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, and SG_NULLMOVE.

template<class BOARD>
SgPoint GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove ( int  numberTries  ) 

Generate a move using the fillboard heuristic.

Tries numberTries times to select a point on the board and returns it, if it is empty and all adjacent and diagonal neighbors are empty. Otherwise it returns SG_NULLMOVE. Using this heuristic before any other heuristics is helpful to increase playout diversity on large boards. See section 6.1 of: Chatriot, Gelly, Hoock, Perez, Rimmel, Teytaud: Combining expert, offline, transient and online learning in Monte-Carlo exploration

Definition at line 161 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::Empty3x3(), SgRandom::Int(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, GoUctPureRandomGenerator< BOARD >::m_invNuPoints, GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat, GoUctPureRandomGenerator< BOARD >::m_random, and SG_NULLMOVE.

template<class BOARD>
void GoUctPureRandomGenerator< BOARD >::Insert ( SgPoint  p  )  [private]

Insert new candidate at random place.

Definition at line 225 of file GoUctPureRandomGenerator.h.

References SgRandom::Int(), GoUctPureRandomGenerator< BOARD >::m_candidates, and GoUctPureRandomGenerator< BOARD >::m_random.

Referenced by GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
void GoUctPureRandomGenerator< BOARD >::OnPlay (  ) 

Update state.

Must be called after each play on the board.

Definition at line 205 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctPureRandomGenerator< BOARD >::Insert(), SgSList< T, SIZE >::IsEmpty(), SgSList< T, SIZE >::Iterator, GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat, SG_NULLMOVE, and SG_PASS.

template<class BOARD>
void GoUctPureRandomGenerator< BOARD >::Start (  ) 

Finds and shuffles the empty points currently on the board.

Definition at line 239 of file GoUctPureRandomGenerator.h.

References GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctPureRandomGenerator< BOARD >::Insert(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, GoUctPureRandomGenerator< BOARD >::m_invNuPoints, and GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat.


Member Data Documentation

template<class BOARD>
const BOARD& GoUctPureRandomGenerator< BOARD >::m_bd [private]

Definition at line 64 of file GoUctPureRandomGenerator.h.

Referenced by GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctPureRandomGenerator< BOARD >::Empty3x3(), GoUctPureRandomGenerator< BOARD >::Generate(), GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
std::vector<SgPoint> GoUctPureRandomGenerator< BOARD >::m_candidates [private]

Points that are potentially empty.

Definition at line 73 of file GoUctPureRandomGenerator.h.

Referenced by GoUctPureRandomGenerator< BOARD >::Candidates(), GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctPureRandomGenerator< BOARD >::Generate(), GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), GoUctPureRandomGenerator< BOARD >::GoUctPureRandomGenerator(), GoUctPureRandomGenerator< BOARD >::Insert(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
float GoUctPureRandomGenerator< BOARD >::m_invNuPoints [private]

Definition at line 66 of file GoUctPureRandomGenerator.h.

Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
float GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat [private]

Definition at line 68 of file GoUctPureRandomGenerator.h.

Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().

template<class BOARD>
SgRandom& GoUctPureRandomGenerator< BOARD >::m_random [private]

Definition at line 70 of file GoUctPureRandomGenerator.h.

Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), and GoUctPureRandomGenerator< BOARD >::Insert().


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


17 Jun 2010 Doxygen 1.4.7