Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

GoUctPlayoutPolicy< BOARD > Class Template Reference

Default playout policy for usage in GoUctGlobalSearch. More...

#include <GoUctPlayoutPolicy.h>

List of all members.

Classes

class  CaptureGenerator
 Incrementally keeps track of blocks in atari. More...

Public Member Functions

 GoUctPlayoutPolicy (const BOARD &bd, const GoUctPlayoutPolicyParam &param)
 Constructor.
GoPointList GetEquivalentBestMoves () const
 Return the list of equivalent best moves from last move generation.
const GoUctPatterns< BOARD > & Patterns () const
 Make pattern matcher available for other uses.
Functions needed by all playout policies.

SgPoint GenerateMove ()
 Generate a move Generates a random move in the following order:

  1. Atari heuristic (if enabled)
  2. Proximity heuristic (if enabled) (using patterns if enabled)
  3. Capture heuristic (if enabled)
  4. Purely random.

void EndPlayout ()
void StartPlayout ()
void OnPlay ()
GoUctPlayoutPolicyType MoveType () const
 Return the type of the last move generated.
Statistics

const GoUctPlayoutPolicyStatStatistics (SgBlackWhite color) const
 Return current statistics.
void ClearStatistics ()

Private Types

typedef bool Corrector (const BOARD &, SgPoint &)
 A function that possibly corrects a given point.

Private Member Functions

bool CorrectMove (typename GoUctPlayoutPolicy< BOARD >::Corrector &corrFunction, SgPoint &mv, GoUctPlayoutPolicyType moveType)
 Try to correct the proposed move, typically by moving it to a 'better' point such as other liberty or neighbor.
bool GenerateAtariCaptureMove ()
 Captures if last move was self-atari.
bool GenerateAtariDefenseMove ()
 Generate escapes if last move was atari.
bool GenerateLowLibMove (SgPoint lastMove)
 Generate low lib moves around lastMove.
bool GenerateNakadeMove ()
 Nakade heuristic.
void GenerateNakadeMove (SgPoint p)
bool GeneratePatternMove ()
 Generate pattern move around last two moves.
void GeneratePatternMove (SgPoint p)
void GeneratePatternMove2 (SgPoint p, SgPoint lastMove)
void GeneratePureRandom ()
bool GeneratePoint (SgPoint p) const
void PlayGoodLiberties (SgPoint block)
 Does playing on a liberty increase number of liberties for block? If yes, add to m_moves.
SgPoint SelectRandom ()
 see GoUctUtil::SelectRandom
void UpdateStatistics ()
 Add statistics for most recently generated move.

Private Attributes

const BOARD & m_bd
const GoUctPlayoutPolicyParamm_param
GoUctPatterns< BOARD > m_patterns
bool m_checked
 m_moves have already been checked, skip GeneratePoint test.
GoUctPlayoutPolicyType m_moveType
 Type of the last generated move.
std::size_t m_nonRandLen
 See GoUctPlayoutPolicyStat::m_nonRandLen.
SgPoint m_lastMove
 Last move.
GoPointList m_moves
 List of equivalent best moves generated by the policy.
SgRandom m_random
SgBalancer m_balancer
 Balancer for GoUctUtil::IsMutualAtari().
CaptureGenerator m_captureGenerator
GoUctPureRandomGenerator< BOARD > m_pureRandomGenerator
SgBWArray< GoUctPlayoutPolicyStatm_statistics

Static Private Attributes

static const bool SECOND_LAST_MOVE_PATTERNS = true
 Use patterns around last own move, too.
static const bool USE_CLUMP_CORRECTION = false
 Shift move to neighbor if it would make an ugly clump.
static const bool DEBUG_CORRECT_MOVE = false

Detailed Description

template<class BOARD>
class GoUctPlayoutPolicy< BOARD >

Default playout policy for usage in GoUctGlobalSearch.

Parametrized by the board class to make it usable with both GoBoard and GoUctBoard. If all heuristics are disabled, the policy plays purely random moves. The order and types of the heuristics are inspired by the first technical report about the MoGo program. Instances of this class must be thread-safe during a search.

Definition at line 104 of file GoUctPlayoutPolicy.h.


Member Typedef Documentation

template<class BOARD>
typedef bool GoUctPlayoutPolicy< BOARD >::Corrector(const BOARD &, SgPoint &) [private]

A function that possibly corrects a given point.

Definition at line 164 of file GoUctPlayoutPolicy.h.


Constructor & Destructor Documentation

template<class BOARD>
GoUctPlayoutPolicy< BOARD >::GoUctPlayoutPolicy ( const BOARD &  bd,
const GoUctPlayoutPolicyParam param 
)

Constructor.

Parameters:
bd 
param The parameters. The policy stores a reference to param to allow changing the parameters of a group of playout policies later. Therefore the lifetime of param must exceed the lifetime of the policy.

Definition at line 342 of file GoUctPlayoutPolicy.h.

References GoUctPlayoutPolicy< BOARD >::ClearStatistics().


Member Function Documentation

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::ClearStatistics (  ) 
template<class BOARD>
bool GoUctPlayoutPolicy< BOARD >::CorrectMove ( typename GoUctPlayoutPolicy< BOARD >::Corrector corrFunction,
SgPoint mv,
GoUctPlayoutPolicyType  moveType 
) [private]

Try to correct the proposed move, typically by moving it to a 'better' point such as other liberty or neighbor.

Examples implemented: self-ataries, clumps.

Definition at line 363 of file GoUctPlayoutPolicy.h.

References GoUctPlayoutPolicy< BOARD >::DEBUG_CORRECT_MOVE, GoUctPlayoutPolicy< BOARD >::m_bd, GoUctPlayoutPolicy< BOARD >::m_moves, GoUctPlayoutPolicy< BOARD >::m_moveType, SgArrayList< T, SIZE >::SetTo(), and SgDebug().

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateMove().

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::EndPlayout (  ) 

Definition at line 386 of file GoUctPlayoutPolicy.h.

Referenced by GoUctDefaultPriorKnowledge::ProcessPosition().

template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GenerateAtariCaptureMove (  )  [private]
template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GenerateAtariDefenseMove (  )  [private]
template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GenerateLowLibMove ( SgPoint  lastMove  )  [private]
template<class BOARD >
SG_ATTR_FLATTEN SgPoint GoUctPlayoutPolicy< BOARD >::GenerateMove (  ) 

Generate a move Generates a random move in the following order:

  1. Atari heuristic (if enabled)
  2. Proximity heuristic (if enabled) (using patterns if enabled)
  3. Capture heuristic (if enabled)
  4. Purely random.

Definition at line 494 of file GoUctPlayoutPolicy.h.

References SgArrayList< T, SIZE >::Clear(), GoUctPlayoutPolicy< BOARD >::CorrectMove(), GoUctUtil::DoClumpCorrection(), GoUctUtil::DoSelfAtariCorrection(), GoUctPlayoutPolicy< BOARD >::CaptureGenerator::Generate(), GoUctPlayoutPolicy< BOARD >::GenerateAtariCaptureMove(), GoUctPlayoutPolicy< BOARD >::GenerateAtariDefenseMove(), GoUctPlayoutPolicy< BOARD >::GenerateLowLibMove(), GoUctPlayoutPolicy< BOARD >::GenerateNakadeMove(), GoUctPlayoutPolicy< BOARD >::GeneratePatternMove(), GOUCT_CLUMP_CORRECTION, GOUCT_SELFATARI_CORRECTION, GoUctPlayoutPolicy< BOARD >::m_balancer, GoUctPlayoutPolicy< BOARD >::m_bd, GoUctPlayoutPolicy< BOARD >::m_captureGenerator, GoUctPlayoutPolicy< BOARD >::m_checked, GoUctPlayoutPolicyParam::m_fillboardTries, GoUctPlayoutPolicy< BOARD >::m_lastMove, GoUctPlayoutPolicy< BOARD >::m_moves, GoUctPlayoutPolicy< BOARD >::m_moveType, GoUctPlayoutPolicy< BOARD >::m_param, GoUctPlayoutPolicy< BOARD >::m_pureRandomGenerator, GoUctPlayoutPolicyParam::m_statisticsEnabled, GoUctPlayoutPolicyParam::m_useNakadeHeuristic, GoUctPlayoutPolicy< BOARD >::SelectRandom(), SG_ASSERT, SG_ATTR_FLATTEN, SG_NULLMOVE, SG_PASS, SgIsSpecialMove(), GoUctPlayoutPolicy< BOARD >::UpdateStatistics(), and GoUctPlayoutPolicy< BOARD >::USE_CLUMP_CORRECTION.

Referenced by GoUctCommands::CmdPolicyMoves(), and GoUctDefaultPriorKnowledge::ProcessPosition().

template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GenerateNakadeMove (  )  [private]

Nakade heuristic.

If there is a region of three empty points adjacent to last move, play in the center of the region.

Definition at line 579 of file GoUctPlayoutPolicy.h.

References SgArrayList< T, SIZE >::IsEmpty(), GoUctPlayoutPolicy< BOARD >::m_lastMove, GoUctPlayoutPolicy< BOARD >::m_moves, SG_ASSERT, SG_NS, SG_WE, and SgIsSpecialMove().

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateMove().

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::GenerateNakadeMove ( SgPoint  p  )  [private]
template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GeneratePatternMove (  )  [private]
template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::GeneratePatternMove ( SgPoint  p  )  [private]
template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::GeneratePatternMove2 ( SgPoint  p,
SgPoint  lastMove 
) [private]
template<class BOARD >
bool GoUctPlayoutPolicy< BOARD >::GeneratePoint ( SgPoint  p  )  const [private]
template<class BOARD>
void GoUctPlayoutPolicy< BOARD >::GeneratePureRandom (  )  [private]
template<class BOARD >
GoPointList GoUctPlayoutPolicy< BOARD >::GetEquivalentBestMoves (  )  const
template<class BOARD >
GoUctPlayoutPolicyType GoUctPlayoutPolicy< BOARD >::MoveType (  )  const

Return the type of the last move generated.

Definition at line 713 of file GoUctPlayoutPolicy.h.

References GoUctPlayoutPolicy< BOARD >::m_moveType.

Referenced by GoUctCommands::CmdPolicyMoves(), and GoUctDefaultPriorKnowledge::ProcessPosition().

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::OnPlay (  ) 
template<class BOARD >
const GoUctPatterns< BOARD > & GoUctPlayoutPolicy< BOARD >::Patterns (  )  const

Make pattern matcher available for other uses.

Avoids that a user of the playout policy who also wants to use the pattern matcher for other purposes needs to allocate a second matcher (Use case: prior knowledge)

Definition at line 728 of file GoUctPlayoutPolicy.h.

References GoUctPlayoutPolicy< BOARD >::m_patterns.

Referenced by GoUctDefaultPriorKnowledge::FindGlobalPatternAndAtariMoves().

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::PlayGoodLiberties ( SgPoint  block  )  [private]

Does playing on a liberty increase number of liberties for block? If yes, add to m_moves.

Disabled if both liberties are simple chain libs, e.g. bamboo.

Definition at line 444 of file GoUctPlayoutPolicy.h.

References GoUctUtil::GainsLiberties(), GoBoardUtil::IsSimpleChain(), GoUctPlayoutPolicy< BOARD >::m_bd, GoUctPlayoutPolicy< BOARD >::m_moves, SgArrayList< T, SIZE >::PushBack(), and GoBoardUtil::SelfAtari().

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateLowLibMove().

template<class BOARD >
SgPoint GoUctPlayoutPolicy< BOARD >::SelectRandom (  )  [private]
template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::StartPlayout (  ) 
template<class BOARD >
const GoUctPlayoutPolicyStat & GoUctPlayoutPolicy< BOARD >::Statistics ( SgBlackWhite  color  )  const

Return current statistics.

The statistics are only collected, if enabled with EnableStatistics().

Definition at line 751 of file GoUctPlayoutPolicy.h.

References GoUctPlayoutPolicy< BOARD >::m_statistics.

template<class BOARD >
void GoUctPlayoutPolicy< BOARD >::UpdateStatistics (  )  [private]

Member Data Documentation

template<class BOARD>
const bool GoUctPlayoutPolicy< BOARD >::DEBUG_CORRECT_MOVE = false [static, private]

Definition at line 195 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::CorrectMove().

template<class BOARD>
SgBalancer GoUctPlayoutPolicy< BOARD >::m_balancer [mutable, private]
template<class BOARD>
const BOARD& GoUctPlayoutPolicy< BOARD >::m_bd [private]
template<class BOARD>
CaptureGenerator GoUctPlayoutPolicy< BOARD >::m_captureGenerator [private]
template<class BOARD>
bool GoUctPlayoutPolicy< BOARD >::m_checked [private]

m_moves have already been checked, skip GeneratePoint test.

Definition at line 204 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateMove(), and GoUctPlayoutPolicy< BOARD >::GetEquivalentBestMoves().

template<class BOARD>
SgPoint GoUctPlayoutPolicy< BOARD >::m_lastMove [private]
template<class BOARD>
GoPointList GoUctPlayoutPolicy< BOARD >::m_moves [private]
template<class BOARD>
GoUctPlayoutPolicyType GoUctPlayoutPolicy< BOARD >::m_moveType [private]
template<class BOARD>
std::size_t GoUctPlayoutPolicy< BOARD >::m_nonRandLen [private]
template<class BOARD>
const GoUctPlayoutPolicyParam& GoUctPlayoutPolicy< BOARD >::m_param [private]

Definition at line 199 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateMove().

template<class BOARD>
GoUctPatterns<BOARD> GoUctPlayoutPolicy< BOARD >::m_patterns [private]
template<class BOARD>
GoUctPureRandomGenerator<BOARD> GoUctPlayoutPolicy< BOARD >::m_pureRandomGenerator [private]
template<class BOARD>
SgRandom GoUctPlayoutPolicy< BOARD >::m_random [private]

Definition at line 224 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::SelectRandom().

template<class BOARD>
SgBWArray<GoUctPlayoutPolicyStat> GoUctPlayoutPolicy< BOARD >::m_statistics [private]
template<class BOARD>
const bool GoUctPlayoutPolicy< BOARD >::SECOND_LAST_MOVE_PATTERNS = true [static, private]

Use patterns around last own move, too.

Definition at line 189 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::GeneratePatternMove().

template<class BOARD>
const bool GoUctPlayoutPolicy< BOARD >::USE_CLUMP_CORRECTION = false [static, private]

Shift move to neighbor if it would make an ugly clump.

See GoUctUtil::DoClumpCorrection

Definition at line 193 of file GoUctPlayoutPolicy.h.

Referenced by GoUctPlayoutPolicy< BOARD >::GenerateMove().


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


Sun Mar 13 2011 Doxygen 1.7.1