libmcts
A Monte Carlo Tree Search Library
Public Types | Public Member Functions | List of all members
mcts::INode< Context, Config > Class Template Referenceabstract

basic interface for a node in the tree. Every node has to implement this functions. More...

#include <inode.hpp>

Inheritance diagram for mcts::INode< Context, Config >:
mcts::InnerNode< Context, Config > mcts::LeafNode< Context, Config >

Public Types

typedef INode< Context, Config > node_t
 

Public Member Functions

virtual void expand ()=0
 expand the current context and add all possible derived contexts as children.
 
virtual node_tparent () const =0
 gets the parent of the current node More...
 
virtual node_tselect_child ()=0
 selects a childnode according to a configurable metric More...
 
virtual node_tselect_recusively ()=0
 recursively selects nodes with a given simulation strategy until an terminal node is reached. More...
 
virtual Config * config () const =0
 gets the config object More...
 
virtual int nb_samples () const =0
 number of times a selection strategy selected the current node. More...
 
virtual const vector< node_t * > children () const =0
 get the children of the current node More...
 
virtual void add_child (node_t *child)=0
 insert a new node as a child of the current one. More...
 
virtual const Context context () const =0
 gets the context associated with the current node More...
 
virtual double ev () const =0
 gets the current expected value. More...
 
virtual double std_dev () const =0
 gets the standard deviation. More...
 
virtual double variance () const =0
 gets the variance. More...
 
virtual double simulate () const =0
 applies a simulation strategy to a terminal node. More...
 
virtual void accept (visitor_t *visitor)=0
 accepts a visitor according to the visitor pattern. More...
 
virtual void backpropagate (const double &value)=0
 applies a backpropagation strategy to traverse the simulated result back up in the tree. More...
 
virtual unsigned count_recursive () const
 recursively counts number of childen beneth this nodes. counts in the current node. More...
 

Detailed Description

template<typename Context, typename Config>
class mcts::INode< Context, Config >

basic interface for a node in the tree. Every node has to implement this functions.

Template Parameters
Context@README
Config@README

Definition at line 18 of file inode.hpp.

Member Function Documentation

◆ accept()

template<typename Context, typename Config>
virtual void mcts::INode< Context, Config >::accept ( visitor_t visitor)
pure virtual

accepts a visitor according to the visitor pattern.

Parameters
visitorobject

Implemented in mcts::InnerNode< Context, Config >, and mcts::LeafNode< Context, Config >.

◆ add_child()

template<typename Context, typename Config>
virtual void mcts::INode< Context, Config >::add_child ( node_t child)
pure virtual

insert a new node as a child of the current one.

Parameters
childpointer to a node

Implemented in mcts::InnerNode< Context, Config >, and mcts::LeafNode< Context, Config >.

◆ backpropagate()

template<typename Context, typename Config>
virtual void mcts::INode< Context, Config >::backpropagate ( const double &  value)
pure virtual

applies a backpropagation strategy to traverse the simulated result back up in the tree.

Parameters
value

Implemented in mcts::InnerNode< Context, Config >.

Referenced by mcts::InnerNode< Context, Config >::backpropagate(), and mcts::MCTS< Context, Config, WrapNode, ResultType >::iterate().

◆ children()

template<typename Context, typename Config>
virtual const vector<node_t *> mcts::INode< Context, Config >::children ( ) const
pure virtual

◆ config()

template<typename Context, typename Config>
virtual Config* mcts::INode< Context, Config >::config ( ) const
pure virtual

◆ context()

template<typename Context, typename Config>
virtual const Context mcts::INode< Context, Config >::context ( ) const
pure virtual

gets the context associated with the current node

Returns
a context

Implemented in mcts::InnerNode< Context, Config >, and mcts::LeafNode< Context, Config >.

◆ count_recursive()

template<typename Context, typename Config>
virtual unsigned mcts::INode< Context, Config >::count_recursive ( ) const
inlinevirtual

recursively counts number of childen beneth this nodes. counts in the current node.

Returns
number of all children + 1

Definition at line 139 of file inode.hpp.

139  {
140  unsigned sum = 0;
141  vector<node_t *> children = this->children();
142  for (unsigned i = 0; i < children.size(); ++i) {
143  sum += children[i]->count_recursive();
144  }
145  return 1 + sum;
146  }
virtual const vector< node_t * > children() const =0
get the children of the current node

Referenced by mcts::MCTS< Context, Config, WrapNode, ResultType >::nb_nodes().

◆ ev()

template<typename Context, typename Config>
virtual double mcts::INode< Context, Config >::ev ( ) const
pure virtual

◆ nb_samples()

template<typename Context, typename Config>
virtual int mcts::INode< Context, Config >::nb_samples ( ) const
pure virtual

◆ parent()

template<typename Context, typename Config>
virtual node_t* mcts::INode< Context, Config >::parent ( ) const
pure virtual

gets the parent of the current node

Returns
pointer to parent

Implemented in mcts::InnerNode< Context, Config >, and mcts::LeafNode< Context, Config >.

Referenced by mcts::UCTSelector< Context, Config >::evaluate().

◆ select_child()

template<typename Context, typename Config>
virtual node_t* mcts::INode< Context, Config >::select_child ( )
pure virtual

selects a childnode according to a configurable metric

Returns
pointer to a child node

Implemented in mcts::LeafNode< Context, Config >, and mcts::InnerNode< Context, Config >.

◆ select_recusively()

template<typename Context, typename Config>
virtual node_t* mcts::INode< Context, Config >::select_recusively ( )
pure virtual

recursively selects nodes with a given simulation strategy until an terminal node is reached.

Returns
pointer to a terminal node

Implemented in mcts::InnerNode< Context, Config >, and mcts::LeafNode< Context, Config >.

Referenced by mcts::MCTS< Context, Config, WrapNode, ResultType >::iterate(), and mcts::InnerNode< Context, Config >::select_recusively().

◆ simulate()

template<typename Context, typename Config>
virtual double mcts::INode< Context, Config >::simulate ( ) const
pure virtual

applies a simulation strategy to a terminal node.

Returns
the expected value of the evaluated context.

Implemented in mcts::InnerNode< Context, Config >.

Referenced by mcts::MCTS< Context, Config, WrapNode, ResultType >::iterate().

◆ std_dev()

template<typename Context, typename Config>
virtual double mcts::INode< Context, Config >::std_dev ( ) const
pure virtual

gets the standard deviation.

Returns
std_dev

Implemented in mcts::InnerNode< Context, Config >.

◆ variance()

template<typename Context, typename Config>
virtual double mcts::INode< Context, Config >::variance ( ) const
pure virtual

gets the variance.

Returns
variance of node

Implemented in mcts::InnerNode< Context, Config >.


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