mainclass to interact with the library. it holds the root of the searchtree.
More...
#include <mcts.hpp>
|
| | MCTS (const Context &context, Config *config) |
| | creates a new empty mcts object. only a root node exists. More...
|
| |
| void | iterate () |
| | executes one interation step. Each iteration consists of the following actions: More...
|
| |
| ResultType | result () |
| | gets the current result node. The node is selected according to a metric defined in a selection strategy. The result is returned to a template container that accepts a node_t* object as constructor. More...
|
| |
| const node_t * | root () const |
| | gets the root of the node. More...
|
| |
| unsigned | nb_nodes () |
| | gets the number of nodes the tree is currently holding. More...
|
| |
| unsigned | nb_iterations () |
| | gets the number of performed iterations. the counter is increased each time the function iterate() is called. More...
|
| |
template<typename Context, typename Config, typename WrapNode, typename ResultType>
class mcts::MCTS< Context, Config, WrapNode, ResultType >
mainclass to interact with the library. it holds the root of the searchtree.
- Template Parameters
-
| Context | @README |
| Config | @README |
| WrapNode | type derived from inner node class |
| ResultType | type of resulttype |
Definition at line 19 of file mcts.hpp.
◆ MCTS()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| mcts::MCTS< Context, Config, WrapNode, ResultType >::MCTS |
( |
const Context & |
context, |
|
|
Config * |
config |
|
) |
| |
|
inline |
creates a new empty mcts object. only a root node exists.
- Parameters
-
| context | base context from which all possible states stem |
| config | a pointer to a config object that stores user defined data and some required functions |
Definition at line 31 of file mcts.hpp.
32 : tree(
new root_node_t(context, config)), iteration_cnt(0) {}
◆ iterate()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| void mcts::MCTS< Context, Config, WrapNode, ResultType >::iterate |
( |
| ) |
|
|
inline |
executes one interation step. Each iteration consists of the following actions:
- select a terminal node
- simulate that node to get it's ev
- backpropagate that value back in the tree
- increase the iteration counter The iteration step expands undexpanded nodes if necessary.
Definition at line 45 of file mcts.hpp.
47 double value = selected_leaf->
simulate();
48 selected_leaf->backpropagate(value);
virtual double simulate() const =0
applies a simulation strategy to a terminal node.
virtual node_t * select_recusively()=0
recursively selects nodes with a given simulation strategy until an terminal node is reached.
◆ nb_iterations()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| unsigned mcts::MCTS< Context, Config, WrapNode, ResultType >::nb_iterations |
( |
| ) |
|
|
inline |
gets the number of performed iterations. the counter is increased each time the function iterate() is called.
- Returns
- number of iterations
Definition at line 84 of file mcts.hpp.
84 {
return iteration_cnt; }
◆ nb_nodes()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| unsigned mcts::MCTS< Context, Config, WrapNode, ResultType >::nb_nodes |
( |
| ) |
|
|
inline |
gets the number of nodes the tree is currently holding.
- Returns
- number of nodes
Definition at line 76 of file mcts.hpp.
virtual unsigned count_recursive() const
recursively counts number of childen beneth this nodes. counts in the current node.
◆ result()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| ResultType mcts::MCTS< Context, Config, WrapNode, ResultType >::result |
( |
| ) |
|
|
inline |
gets the current result node. The node is selected according to a metric defined in a selection strategy. The result is returned to a template container that accepts a node_t* object as constructor.
- Returns
- a resultobject
Definition at line 60 of file mcts.hpp.
61 return ResultType(tree->
config()->move_selector()->select(tree));
virtual Config * config() const =0
gets the config object
◆ root()
template<typename Context , typename Config , typename WrapNode , typename ResultType >
| const node_t* mcts::MCTS< Context, Config, WrapNode, ResultType >::root |
( |
| ) |
const |
|
inline |
gets the root of the node.
- Returns
- pointer to root node.
Definition at line 69 of file mcts.hpp.
The documentation for this class was generated from the following file: