Randomly select from empty points on the board. More...
#include <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 |
SgRandom & | m_random |
std::vector< SgPoint > | m_candidates |
Points that are potentially empty. |
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 29 of file GoUctPureRandomGenerator.h.
GoUctPureRandomGenerator< BOARD >::GoUctPureRandomGenerator | ( | const BOARD & | bd, | |
SgRandom & | random | |||
) |
Definition at line 88 of file GoUctPureRandomGenerator.h.
References GO_MAX_NUM_MOVES, and GoUctPureRandomGenerator< BOARD >::m_candidates.
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 98 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::m_candidates.
void GoUctPureRandomGenerator< BOARD >::CheckConsistency | ( | ) | const [private] |
Definition at line 105 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().
bool GoUctPureRandomGenerator< BOARD >::Empty3x3 | ( | SgPoint | p | ) | const [private] |
Definition at line 130 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::m_bd.
Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove().
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 138 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctUtil::GeneratePoint(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, and SG_NULLMOVE.
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 166 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::Empty3x3(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_candidates, GoUctPureRandomGenerator< BOARD >::m_invNuPoints, GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat, GoUctPureRandomGenerator< BOARD >::m_random, SG_NULLMOVE, and SgRandom::SmallInt().
void GoUctPureRandomGenerator< BOARD >::Insert | ( | SgPoint | p | ) | [private] |
Insert new candidate at random place.
Definition at line 231 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::m_candidates, GoUctPureRandomGenerator< BOARD >::m_random, and SgRandom::SmallInt().
Referenced by GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().
void GoUctPureRandomGenerator< BOARD >::OnPlay | ( | ) |
Update state.
Must be called after each play on the board.
Definition at line 211 of file GoUctPureRandomGenerator.h.
References GoUctPureRandomGenerator< BOARD >::CheckConsistency(), GoUctPureRandomGenerator< BOARD >::Insert(), SgArrayList< T, SIZE >::IsEmpty(), SgArrayList< SgPoint, SG_MAX_ONBOARD+1 >::Iterator, SgArrayList< T, SIZE >::Length(), GoUctPureRandomGenerator< BOARD >::m_bd, GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat, SG_NULLMOVE, and SG_PASS.
void GoUctPureRandomGenerator< BOARD >::Start | ( | ) |
Finds and shuffles the empty points currently on the board.
Definition at line 245 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.
const BOARD& GoUctPureRandomGenerator< BOARD >::m_bd [private] |
Definition at line 69 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().
std::vector<SgPoint> GoUctPureRandomGenerator< BOARD >::m_candidates [private] |
Points that are potentially empty.
Definition at line 78 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().
float GoUctPureRandomGenerator< BOARD >::m_invNuPoints [private] |
Definition at line 71 of file GoUctPureRandomGenerator.h.
Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), and GoUctPureRandomGenerator< BOARD >::Start().
float GoUctPureRandomGenerator< BOARD >::m_nuEmptyFloat [private] |
Definition at line 73 of file GoUctPureRandomGenerator.h.
Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), GoUctPureRandomGenerator< BOARD >::OnPlay(), and GoUctPureRandomGenerator< BOARD >::Start().
SgRandom& GoUctPureRandomGenerator< BOARD >::m_random [private] |
Definition at line 75 of file GoUctPureRandomGenerator.h.
Referenced by GoUctPureRandomGenerator< BOARD >::GenerateFillboardMove(), and GoUctPureRandomGenerator< BOARD >::Insert().