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

SgUctNode Class Reference
[Monte Carlo tree search]

Node used in SgUctTree. More...

#include <SgUctTree.h>

List of all members.

Public Member Functions

 SgUctNode (const SgUctMoveInfo &info)
 Initializes node with given move, value and count.
void AddGameResult (SgUctValue eval)
 Add game result.
void AddGameResults (SgUctValue eval, SgUctValue count)
 Adds a game result count times.
void MergeResults (const SgUctNode &node)
 Add other nodes results to this node's.
void RemoveGameResult (SgUctValue eval)
 Removes a game result.
void RemoveGameResults (SgUctValue eval, SgUctValue count)
 Removes a game result count times.
SgUctValue PosCount () const
 Number of times this node was visited.
SgUctValue MoveCount () const
 Number of times the move leading to this position was chosen.
const SgUctNodeFirstChild () const
 Get first child.
bool HasChildren () const
 Does the node have at least one child?
SgUctValue Mean () const
 Average game result.
bool HasMean () const
 True, if mean value is defined (move count not zero).
int NuChildren () const
 Get number of children.
void SetFirstChild (const SgUctNode *child)
 See FirstChild().
void SetNuChildren (int nuChildren)
 See NuChildren().
void IncPosCount ()
 Increment the position count.
void IncPosCount (SgUctValue count)
 Increment the position count.
void DecPosCount ()
 Decrement the position count.
void DecPosCount (SgUctValue count)
 Decrement the position count.
void SetPosCount (SgUctValue value)
void InitializeValue (SgUctValue value, SgUctValue count)
 Initialize value with prior knowledge.
void CopyDataFrom (const SgUctNode &node)
 Copy data from other node.
SgMove Move () const
 Get move.
SgUctValue RaveCount () const
 Get RAVE count.
SgUctValue RaveValue () const
 Get RAVE mean value.
bool HasRaveValue () const
void AddRaveValue (SgUctValue value, SgUctValue weight)
 Add a game result value to the RAVE value.
void RemoveRaveValue (SgUctValue value)
 Removes a rave result.
void RemoveRaveValue (SgUctValue value, SgUctValue weight)
void InitializeRaveValue (SgUctValue value, SgUctValue count)
 Initialize RAVE value with prior knowledge.
int VirtualLossCount () const
void AddVirtualLoss ()
void RemoveVirtualLoss ()
SgUctValue KnowledgeCount () const
 Returns the last time knowledge was computed.
void SetKnowledgeCount (SgUctValue count)
 Set that knowledge has been computed at count.
bool IsProven () const
 Returns true if node is a proven node.
bool IsProvenWin () const
bool IsProvenLoss () const
SgUctProvenType ProvenType () const
void SetProvenType (SgUctProvenType type)

Private Attributes

SgUctStatisticsVolatile m_statistics
const SgUctNode *volatile m_firstChild
volatile int m_nuChildren
volatile SgMove m_move
SgUctStatisticsVolatile m_raveValue
 RAVE statistics.
volatile SgUctValue m_posCount
volatile SgUctValue m_knowledgeCount
volatile SgUctProvenType m_provenType
volatile int m_virtualLossCount

Detailed Description

Node used in SgUctTree.

All data members are declared as volatile to avoid that the compiler re-orders writes, which can break assumptions made by SgUctSearch in lock-free mode (see Lock-free mode in SgUctSearch). For example, the search relies on the fact that m_firstChild is valid, if m_nuChildren is greater zero or that the mean value of the move and RAVE value statistics is valid if the corresponding count is greater zero.

Definition at line 111 of file SgUctTree.h.


Constructor & Destructor Documentation

SgUctNode::SgUctNode ( const SgUctMoveInfo info  ) 

Initializes node with given move, value and count.

Definition at line 270 of file SgUctTree.h.


Member Function Documentation

void SgUctNode::AddGameResult ( SgUctValue  eval  ) 

Add game result.

Parameters:
eval The game result (e.g. score or 0/1 for win loss)

Definition at line 283 of file SgUctTree.h.

References SgStatisticsVltBase< VALUE, COUNT >::Add(), and m_statistics.

void SgUctNode::AddGameResults ( SgUctValue  eval,
SgUctValue  count 
)

Adds a game result count times.

Definition at line 288 of file SgUctTree.h.

References SgStatisticsVltBase< VALUE, COUNT >::Add(), and m_statistics.

void SgUctNode::AddRaveValue ( SgUctValue  value,
SgUctValue  weight 
)

Add a game result value to the RAVE value.

See also:
SgUctSearch::Rave().

Definition at line 311 of file SgUctTree.h.

References SgStatisticsVltBase< VALUE, COUNT >::Add(), and m_raveValue.

void SgUctNode::AddVirtualLoss (  ) 

Definition at line 363 of file SgUctTree.h.

References m_virtualLossCount.

void SgUctNode::CopyDataFrom ( const SgUctNode node  ) 

Copy data from other node.

Copies all data, apart from the children information (first child and number of children).

Definition at line 326 of file SgUctTree.h.

References m_knowledgeCount, m_move, m_posCount, m_provenType, m_raveValue, m_statistics, and m_virtualLossCount.

Referenced by SgUctTree::ApplyFilter(), SgUctTree::CopySubtree(), and SgUctTree::SetChildren().

void SgUctNode::DecPosCount (  ) 

Decrement the position count.

See PosCount()

Definition at line 386 of file SgUctTree.h.

References m_posCount.

void SgUctNode::DecPosCount ( SgUctValue  count  ) 

Decrement the position count.

See PosCount()

Definition at line 395 of file SgUctTree.h.

References m_posCount.

const SgUctNode * SgUctNode::FirstChild (  )  const

Get first child.

Note:
This information is an implementation detail of how SgUctTree manages nodes. Use SgUctChildIterator to access children nodes.

Definition at line 337 of file SgUctTree.h.

References HasChildren(), m_firstChild, and SG_ASSERT.

Referenced by SgUctTree::MergeChildren(), SgUctSearch::SelectChild(), and SgUctChildIterator::SgUctChildIterator().

bool SgUctNode::HasChildren (  )  const
bool SgUctNode::HasMean (  )  const
bool SgUctNode::HasRaveValue (  )  const
void SgUctNode::IncPosCount ( SgUctValue  count  ) 

Increment the position count.

See PosCount()

Definition at line 381 of file SgUctTree.h.

References m_posCount.

void SgUctNode::IncPosCount (  ) 

Increment the position count.

See PosCount()

Definition at line 376 of file SgUctTree.h.

References m_posCount.

void SgUctNode::InitializeRaveValue ( SgUctValue  value,
SgUctValue  count 
)

Initialize RAVE value with prior knowledge.

Definition at line 409 of file SgUctTree.h.

References SgStatisticsVltBase< VALUE, COUNT >::Initialize(), and m_raveValue.

void SgUctNode::InitializeValue ( SgUctValue  value,
SgUctValue  count 
)

Initialize value with prior knowledge.

Definition at line 404 of file SgUctTree.h.

References SgStatisticsVltBase< VALUE, COUNT >::Initialize(), and m_statistics.

bool SgUctNode::IsProven (  )  const

Returns true if node is a proven node.

Definition at line 476 of file SgUctTree.h.

References m_provenType.

Referenced by SgUctSearch::CheckAbortSearch(), SgUctTree::CopySubtree(), SgUctSearch::PlayInTree(), and SgUctSearch::PropagateProvenStatus().

bool SgUctNode::IsProvenLoss (  )  const

Definition at line 486 of file SgUctTree.h.

References m_provenType.

Referenced by SgUctSearch::FindBestChild(), and SgUctSearch::PropagateProvenStatus().

bool SgUctNode::IsProvenWin (  )  const

Definition at line 481 of file SgUctTree.h.

References m_provenType.

Referenced by SgUctSearch::CheckAbortSearch(), and SgUctSearch::SelectChild().

SgUctValue SgUctNode::KnowledgeCount (  )  const

Returns the last time knowledge was computed.

Definition at line 466 of file SgUctTree.h.

References m_knowledgeCount.

Referenced by SgUctTree::MergeChildren(), SgUctSearch::NeedToComputeKnowledge(), and SgUctSearch::PlayInTree().

SgUctValue SgUctNode::Mean (  )  const
void SgUctNode::MergeResults ( const SgUctNode node  ) 
SgMove SgUctNode::Move (  )  const
SgUctValue SgUctNode::MoveCount (  )  const
int SgUctNode::NuChildren (  )  const

Get number of children.

Note:
This information is an implementation detail of how SgUctTree manages nodes. Use SgUctChildIterator to access children nodes.

Definition at line 430 of file SgUctTree.h.

References m_nuChildren.

Referenced by SgUctTree::ApplyFilter(), SgUctTree::CopySubtree(), SgUctTree::MergeChildren(), SgUctChildIterator::SgUctChildIterator(), and SgUctSearch::StartSearch().

SgUctValue SgUctNode::PosCount (  )  const

Number of times this node was visited.

This corresponds to the sum of MoveCount() of all children. It can be different from MoveCount() of this position, if prior knowledge initialization of the children is used.

Definition at line 435 of file SgUctTree.h.

References m_posCount.

Referenced by SgUctSearch::GetBound(), SgUctTree::MergeChildren(), and SgUctSearch::SelectChild().

SgUctProvenType SgUctNode::ProvenType (  )  const

Definition at line 491 of file SgUctTree.h.

References m_provenType.

SgUctValue SgUctNode::RaveCount (  )  const
SgUctValue SgUctNode::RaveValue (  )  const
void SgUctNode::RemoveGameResult ( SgUctValue  eval  ) 

Removes a game result.

Parameters:
eval The game result (e.g. score or 0/1 for win loss)

Definition at line 301 of file SgUctTree.h.

References m_statistics, and SgStatisticsVltBase< VALUE, COUNT >::Remove().

void SgUctNode::RemoveGameResults ( SgUctValue  eval,
SgUctValue  count 
)

Removes a game result count times.

Definition at line 306 of file SgUctTree.h.

References m_statistics, and SgStatisticsVltBase< VALUE, COUNT >::Remove().

void SgUctNode::RemoveRaveValue ( SgUctValue  value,
SgUctValue  weight 
)

Definition at line 321 of file SgUctTree.h.

References m_raveValue, and SgStatisticsVltBase< VALUE, COUNT >::Remove().

void SgUctNode::RemoveRaveValue ( SgUctValue  value  ) 

Removes a rave result.

Definition at line 316 of file SgUctTree.h.

References m_raveValue, and SgStatisticsVltBase< VALUE, COUNT >::Remove().

void SgUctNode::RemoveVirtualLoss (  ) 

Definition at line 368 of file SgUctTree.h.

References m_virtualLossCount.

void SgUctNode::SetFirstChild ( const SgUctNode child  ) 
void SgUctNode::SetKnowledgeCount ( SgUctValue  count  ) 

Set that knowledge has been computed at count.

Definition at line 471 of file SgUctTree.h.

References m_knowledgeCount.

Referenced by SgUctTree::MergeChildren().

void SgUctNode::SetNuChildren ( int  nuChildren  ) 
void SgUctNode::SetPosCount ( SgUctValue  value  ) 

Definition at line 461 of file SgUctTree.h.

References m_posCount.

Referenced by SgUctTree::CopySubtree(), SgUctTree::CreateChildren(), and SgUctTree::MergeChildren().

void SgUctNode::SetProvenType ( SgUctProvenType  type  ) 

Definition at line 496 of file SgUctTree.h.

References m_provenType.

Referenced by SgUctTree::CopySubtree().

int SgUctNode::VirtualLossCount (  )  const

Member Data Documentation

const SgUctNode* volatile SgUctNode::m_firstChild [private]

Definition at line 250 of file SgUctTree.h.

Referenced by FirstChild(), and SetFirstChild().

Definition at line 263 of file SgUctTree.h.

Referenced by CopyDataFrom(), KnowledgeCount(), and SetKnowledgeCount().

volatile SgMove SgUctNode::m_move [private]

Definition at line 254 of file SgUctTree.h.

Referenced by CopyDataFrom(), and Move().

volatile int SgUctNode::m_nuChildren [private]

Definition at line 252 of file SgUctTree.h.

Referenced by HasChildren(), NuChildren(), and SetNuChildren().

volatile SgUctValue SgUctNode::m_posCount [private]

Definition at line 261 of file SgUctTree.h.

Referenced by CopyDataFrom(), DecPosCount(), IncPosCount(), PosCount(), and SetPosCount().

RAVE statistics.

Uses double for count to allow adding fractional values if RAVE updates are weighted.

Definition at line 259 of file SgUctTree.h.

Referenced by AddRaveValue(), CopyDataFrom(), HasRaveValue(), InitializeRaveValue(), MergeResults(), RaveCount(), RaveValue(), and RemoveRaveValue().

volatile int SgUctNode::m_virtualLossCount [private]

Definition at line 267 of file SgUctTree.h.

Referenced by AddVirtualLoss(), CopyDataFrom(), RemoveVirtualLoss(), and VirtualLossCount().


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


Sun Mar 13 2011 Doxygen 1.7.1