Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgUctAllocator Class Reference
[Monte Carlo tree search]

#include <SgUctTree.h>

List of all members.


Detailed Description

Allocater for nodes used in the implementation of SgUctTree.

Each thread has its own node allocator to allow lock-free usage of SgUctTree.

Definition at line 471 of file SgUctTree.h.

Public Member Functions

 SgUctAllocator ()
 ~SgUctAllocator ()
void Clear ()
bool HasCapacity (std::size_t n) const
 Does the allocator have the capacity for n more nodes?
std::size_t NuNodes () const
std::size_t MaxNodes () const
void SetMaxNodes (std::size_t maxNodes)
bool Contains (const SgUctNode &node) const
 Check if allocator contains node.
const SgUctNodeStart () const
SgUctNodeFinish ()
const SgUctNodeFinish () const
SgUctNodeCreateOne (SgMove move)
 Create a new node at the end of the storage.
std::size_t Create (const std::vector< SgMoveInfo > &moves)
 Create a number of new nodes with a given list of moves at the end of the storage.
void CreateN (std::size_t n)
 Create a number of new nodes at the end of the storage.
void Swap (SgUctAllocator &allocator)

Private Member Functions

SgUctAllocatoroperator= (const SgUctAllocator &tree)
 Not implemented.

Private Attributes

SgUctNodem_start
SgUctNodem_finish
SgUctNodem_endOfStorage


Constructor & Destructor Documentation

SgUctAllocator::SgUctAllocator (  ) 

Definition at line 540 of file SgUctTree.h.

References m_start.

SgUctAllocator::~SgUctAllocator (  ) 

Definition at line 20 of file SgUctTree.cpp.

References Clear(), and m_start.


Member Function Documentation

void SgUctAllocator::Clear (  ) 

Definition at line 545 of file SgUctTree.h.

References m_finish, and m_start.

Referenced by SgUctTree::Clear(), SetMaxNodes(), and ~SgUctAllocator().

bool SgUctAllocator::Contains ( const SgUctNode node  )  const

Check if allocator contains node.

This function uses pointer comparisons. Since the result of comparisons for pointers to elements in different containers is platform-dependent, it is only guaranteed that it returns true, if not node belongs to the allocator, but not that it returns false for nodes not in the allocator.

Definition at line 29 of file SgUctTree.cpp.

References m_finish, and m_start.

std::size_t SgUctAllocator::Create ( const std::vector< SgMoveInfo > &  moves  ) 

Create a number of new nodes with a given list of moves at the end of the storage.

Returns the sum of counts of moves. REQUIRES: HasCapacity(moves.size())

Parameters:
moves The list of moves.

Definition at line 562 of file SgUctTree.h.

References HasCapacity(), m_finish, and SG_ASSERT.

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

void SgUctAllocator::CreateN ( std::size_t  n  ) 

Create a number of new nodes at the end of the storage.

REQUIRES: HasCapacity(n)

Parameters:
n The number of nodes to create.

Definition at line 576 of file SgUctTree.h.

References HasCapacity(), m_finish, SG_ASSERT, and SG_NULLMOVE.

Referenced by SgUctTree::CopySubtree().

SgUctNode * SgUctAllocator::CreateOne ( SgMove  move  ) 

Create a new node at the end of the storage.

REQUIRES: HasCapacity(1)

Parameters:
move The constructor argument.
Returns:
A pointer to new newly created node.

Definition at line 555 of file SgUctTree.h.

References HasCapacity(), m_finish, and SG_ASSERT.

Referenced by SgUctTree::ApplyFilter().

const SgUctNode * SgUctAllocator::Finish (  )  const

Definition at line 589 of file SgUctTree.h.

References m_finish.

SgUctNode * SgUctAllocator::Finish (  ) 

Definition at line 584 of file SgUctTree.h.

References m_finish.

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

bool SgUctAllocator::HasCapacity ( std::size_t  n  )  const

Does the allocator have the capacity for n more nodes?

Definition at line 594 of file SgUctTree.h.

References m_endOfStorage, and m_finish.

Referenced by SgUctTree::CopySubtree(), Create(), SgUctTree::CreateChildren(), CreateN(), CreateOne(), SgUctTree::HasCapacity(), and SgUctTree::MergeChildren().

std::size_t SgUctAllocator::MaxNodes (  )  const

Definition at line 599 of file SgUctTree.h.

References m_endOfStorage, and m_start.

std::size_t SgUctAllocator::NuNodes (  )  const

Definition at line 604 of file SgUctTree.h.

References m_finish, and m_start.

Referenced by SgUctTree::DumpDebugInfo(), and SgUctTree::NuNodes().

SgUctAllocator& SgUctAllocator::operator= ( const SgUctAllocator tree  )  [private]

Not implemented.

Cannot be copied because array contains pointers to elements. Use Swap() instead.

void SgUctAllocator::SetMaxNodes ( std::size_t  maxNodes  ) 

Definition at line 41 of file SgUctTree.cpp.

References Clear(), m_endOfStorage, m_finish, and m_start.

Referenced by SgUctTree::SetMaxNodes().

const SgUctNode * SgUctAllocator::Start (  )  const

Definition at line 609 of file SgUctTree.h.

References m_start.

Referenced by SgUctTree::DumpDebugInfo().

void SgUctAllocator::Swap ( SgUctAllocator allocator  ) 

Definition at line 34 of file SgUctTree.cpp.

References m_endOfStorage, m_finish, and m_start.

Referenced by SgUctTree::Swap().


Member Data Documentation

SgUctNode* SgUctAllocator::m_endOfStorage [private]

Definition at line 531 of file SgUctTree.h.

Referenced by HasCapacity(), MaxNodes(), SetMaxNodes(), and Swap().

SgUctNode* SgUctAllocator::m_finish [private]

Definition at line 529 of file SgUctTree.h.

Referenced by Clear(), Contains(), Create(), CreateN(), CreateOne(), Finish(), HasCapacity(), NuNodes(), SetMaxNodes(), and Swap().

SgUctNode* SgUctAllocator::m_start [private]

Definition at line 527 of file SgUctTree.h.

Referenced by Clear(), Contains(), MaxNodes(), NuNodes(), SetMaxNodes(), SgUctAllocator(), Start(), Swap(), and ~SgUctAllocator().


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


17 Jun 2010 Doxygen 1.4.7