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

GoUctBookBuilder< PLAYER > Class Template Reference

Expands a Book using the given player to evaluate game positions. More...

#include <GoUctBookBuilder.h>

Inheritance diagram for GoUctBookBuilder< PLAYER >:
Inheritance graph
[legend]

List of all members.

Classes

class  Worker
 Copyable worker. More...

Public Member Functions

 GoUctBookBuilder (const GoBoard &brd)
 ~GoUctBookBuilder ()
void SetPlayer (PLAYER &player)
 Sets the player to use.
void SetState (GoAutoBook &book)
 Sets the state to start work from.
std::size_t NumThreads () const
 Number of players to use during leaf expansion.
void SetNumThreads (std::size_t num)
 See NumThreads().
SgUctValue NumGamesPerEvaluation () const
 Number of games to play when evaluation a state.
void SetNumGamesPerEvaluation (SgUctValue num)
 See NumGamesPerEvaluation().
SgUctValue NumGamesPerSort () const
 Number of games to play when sorting children.
void SetNumGamesPerSort (SgUctValue num)
 See NumGamesForSort().
float InverseEval (float eval) const
bool IsLoss (float eval) const
float Value (const SgBookNode &node) const
void Expand (int numExpansions)
void Cover (int requiredExpansions, bool additive, const std::vector< std::vector< SgMove > > &lines)
void Refresh ()
void IncreaseWidth ()
float Alpha () const
void SetAlpha (float alpha)
bool UseWidening () const
void SetUseWidening (bool flag)
std::size_t ExpandWidth () const
void SetExpandWidth (std::size_t width)
std::size_t ExpandThreshold () const
void SetExpandThreshold (std::size_t threshold)
float ComputePriority (const SgBookNode &parent, const float childValue, const float childPriority) const

Protected Member Functions

std::string MoveString (SgMove move) const
void PrintMessage (std::string msg)
void PlayMove (SgMove move)
void UndoMove (SgMove move)
bool GetNode (SgBookNode &node) const
void WriteNode (const SgBookNode &node)
void FlushBook ()
void EnsureRootExists ()
 Creates root node if necessary.
bool GenerateMoves (std::vector< SgMove > &moves, float &value)
 Computes an ordered set of moves to consider.
void GetAllLegalMoves (std::vector< SgMove > &moves)
void EvaluateChildren (const std::vector< SgMove > &childrenToDo, std::vector< std::pair< SgMove, float > > &scores)
void Init ()
void StartIteration ()
void EndIteration ()
void BeforeEvaluateChildren ()
void AfterEvaluateChildren ()
void Fini ()
void ClearAllVisited ()
void MarkAsVisited ()
bool HasBeenVisited ()

Protected Attributes

float m_alpha
bool m_useWidening
std::size_t m_expandWidth
std::size_t m_expandThreshold
std::size_t m_flushIterations

Private Member Functions

void CreateWorkers ()
 Copies the player and board and creates the threads.
void DestroyWorkers ()
 Destroys copied players, boards, and threads.

Private Attributes

GoAutoBookm_book
 Book this builder is expanding.
PLAYER * m_origPlayer
GoAutoBookState m_state
std::set< SgHashCodem_visited
std::size_t m_numThreads
 See NumberThreads().
SgUctValue m_numGamesPerEvaluation
 See NumGamesPerEvaluation.
SgUctValue m_numGamesPerSort
 See NumGamesForSort().
std::size_t m_numEvals
std::size_t m_numWidenings
std::size_t m_valueUpdates
std::size_t m_priorityUpdates
std::size_t m_internalNodes
std::size_t m_leafNodes
std::size_t m_terminalNodes
std::vector< PLAYER * > m_players
 Players for each thread.
std::vector< Workerm_workers
 Workers for each thread.
SgThreadedWorker< SgMove,
float, Worker > * 
m_threadedWorker

Detailed Description

template<class PLAYER>
class GoUctBookBuilder< PLAYER >

Expands a Book using the given player to evaluate game positions.

Supports multithreaded evaluation of children.

Todo:
Copy settings from passed player to other players.

Definition at line 24 of file GoUctBookBuilder.h.


Constructor & Destructor Documentation

template<class PLAYER >
GoUctBookBuilder< PLAYER >::GoUctBookBuilder ( const GoBoard brd  ) 
template<class PLAYER >
GoUctBookBuilder< PLAYER >::~GoUctBookBuilder (  ) 

Definition at line 228 of file GoUctBookBuilder.h.


Member Function Documentation

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::AfterEvaluateChildren (  )  [protected, virtual]

Reimplemented from SgBookBuilder.

Definition at line 463 of file GoUctBookBuilder.h.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::BeforeEvaluateChildren (  )  [protected, virtual]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::ClearAllVisited (  )  [protected, virtual]

Implements SgBookBuilder.

Definition at line 478 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_visited.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::CreateWorkers (  )  [private]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::DestroyWorkers (  )  [private]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::EndIteration (  )  [protected, virtual]

Reimplemented from SgBookBuilder.

Definition at line 473 of file GoUctBookBuilder.h.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::EnsureRootExists (  )  [protected, virtual]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::EvaluateChildren ( const std::vector< SgMove > &  childrenToDo,
std::vector< std::pair< SgMove, float > > &  scores 
) [protected, virtual]

Implements SgBookBuilder.

Definition at line 452 of file GoUctBookBuilder.h.

References SgDebug().

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::Fini (  )  [protected, virtual]

Reimplemented from SgBookBuilder.

Definition at line 280 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::DestroyWorkers().

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::FlushBook (  )  [protected, virtual]

Implements SgBookBuilder.

Definition at line 373 of file GoUctBookBuilder.h.

References GoAutoBook::Flush(), GoUctBookBuilder< PLAYER >::m_book, and SgDebug().

template<class PLAYER >
bool GoUctBookBuilder< PLAYER >::GenerateMoves ( std::vector< SgMove > &  moves,
float &  value 
) [protected, virtual]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::GetAllLegalMoves ( std::vector< SgMove > &  moves  )  [protected, virtual]
template<class PLAYER >
bool GoUctBookBuilder< PLAYER >::GetNode ( SgBookNode node  )  const [protected, virtual]
template<class PLAYER >
bool GoUctBookBuilder< PLAYER >::HasBeenVisited (  )  [protected, virtual]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::Init (  )  [protected, virtual]

Reimplemented from SgBookBuilder.

Definition at line 274 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::CreateWorkers().

template<class PLAYER >
float GoUctBookBuilder< PLAYER >::InverseEval ( float  eval  )  const [virtual]

Implements SgBookBuilder.

Definition at line 336 of file GoUctBookBuilder.h.

template<class PLAYER >
bool GoUctBookBuilder< PLAYER >::IsLoss ( float  eval  )  const [virtual]

Implements SgBookBuilder.

Definition at line 342 of file GoUctBookBuilder.h.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::MarkAsVisited (  )  [protected, virtual]
template<class PLAYER >
std::string GoUctBookBuilder< PLAYER >::MoveString ( SgMove  move  )  const [protected, virtual]

Implements SgBookBuilder.

Definition at line 324 of file GoUctBookBuilder.h.

References SgPointUtil::PointToString().

template<class PLAYER >
SgUctValue GoUctBookBuilder< PLAYER >::NumGamesPerEvaluation (  )  const

Number of games to play when evaluation a state.

Definition at line 188 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_numGamesPerEvaluation.

template<class PLAYER >
SgUctValue GoUctBookBuilder< PLAYER >::NumGamesPerSort (  )  const

Number of games to play when sorting children.

Definition at line 200 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_numGamesPerSort.

template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::NumThreads (  )  const

Number of players to use during leaf expansion.

Each player may use a multi-threaded search. Should speed up the expansion of leaf states by a factor of (very close to) NumThreads().

Definition at line 176 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_numThreads.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::PlayMove ( SgMove  move  )  [protected, virtual]

Implements SgBookBuilder.

Definition at line 348 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_state, and GoAutoBookState::Play().

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::PrintMessage ( std::string  msg  )  [protected, virtual]
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::SetNumGamesPerEvaluation ( SgUctValue  num  ) 
template<class PLAYER >
void GoUctBookBuilder< PLAYER >::SetNumGamesPerSort ( SgUctValue  num  ) 

See NumGamesForSort().

Definition at line 206 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_numGamesPerSort.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::SetNumThreads ( std::size_t  num  ) 

See NumThreads().

Definition at line 182 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_numThreads.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::SetPlayer ( PLAYER &  player  ) 

Sets the player to use.

Settings are copied from this player to the players used for each thread.

Todo:
Currently not used! Since it is not clear how to copy settings from one player to another nicely.

Definition at line 311 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_origPlayer.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::SetState ( GoAutoBook book  ) 

Sets the state to start work from.

Definition at line 317 of file GoUctBookBuilder.h.

References GoUctBookBuilder< PLAYER >::m_book, GoUctBookBuilder< PLAYER >::m_state, and GoAutoBookState::Synchronize().

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::StartIteration (  )  [protected, virtual]

Reimplemented from SgBookBuilder.

Definition at line 468 of file GoUctBookBuilder.h.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::UndoMove ( SgMove  move  )  [protected, virtual]
template<class PLAYER >
float GoUctBookBuilder< PLAYER >::Value ( const SgBookNode node  )  const [virtual]

Implements SgBookBuilder.

Definition at line 380 of file GoUctBookBuilder.h.

References SgBookNode::m_value.

template<class PLAYER >
void GoUctBookBuilder< PLAYER >::WriteNode ( const SgBookNode node  )  [protected, virtual]

Member Data Documentation

template<class PLAYER >
GoAutoBook* GoUctBookBuilder< PLAYER >::m_book [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_internalNodes [private]

Reimplemented from SgBookBuilder.

Definition at line 154 of file GoUctBookBuilder.h.

template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_leafNodes [private]

Reimplemented from SgBookBuilder.

Definition at line 156 of file GoUctBookBuilder.h.

template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_numEvals [private]

Reimplemented from SgBookBuilder.

Definition at line 146 of file GoUctBookBuilder.h.

template<class PLAYER >
SgUctValue GoUctBookBuilder< PLAYER >::m_numGamesPerEvaluation [private]
template<class PLAYER >
SgUctValue GoUctBookBuilder< PLAYER >::m_numGamesPerSort [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_numThreads [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_numWidenings [private]

Reimplemented from SgBookBuilder.

Definition at line 148 of file GoUctBookBuilder.h.

template<class PLAYER >
PLAYER* GoUctBookBuilder< PLAYER >::m_origPlayer [private]

Definition at line 131 of file GoUctBookBuilder.h.

Referenced by GoUctBookBuilder< PLAYER >::SetPlayer().

template<class PLAYER >
std::vector<PLAYER*> GoUctBookBuilder< PLAYER >::m_players [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_priorityUpdates [private]

Reimplemented from SgBookBuilder.

Definition at line 152 of file GoUctBookBuilder.h.

template<class PLAYER >
GoAutoBookState GoUctBookBuilder< PLAYER >::m_state [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_terminalNodes [private]

Reimplemented from SgBookBuilder.

Definition at line 158 of file GoUctBookBuilder.h.

template<class PLAYER >
SgThreadedWorker<SgMove,float,Worker>* GoUctBookBuilder< PLAYER >::m_threadedWorker [private]
template<class PLAYER >
std::size_t GoUctBookBuilder< PLAYER >::m_valueUpdates [private]

Reimplemented from SgBookBuilder.

Definition at line 150 of file GoUctBookBuilder.h.

template<class PLAYER >
std::set<SgHashCode> GoUctBookBuilder< PLAYER >::m_visited [private]
template<class PLAYER >
std::vector<Worker> GoUctBookBuilder< PLAYER >::m_workers [private]

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


Sun Mar 13 2011 Doxygen 1.7.1