4 #include "root_node.hpp" 17 template <
typename Context,
typename Config,
typename WrapNode,
31 MCTS(
const Context &context, Config *config)
32 : tree(new
root_node_t(context, config)), iteration_cnt(0) {}
34 virtual ~
MCTS() {
delete tree; }
47 double value = selected_leaf->
simulate();
61 return ResultType(tree->
config()->move_selector()->select(tree));
89 unsigned iteration_cnt;
special node that is the root of each tree. Its merely a wrapper that wrapps around a inner node.
unsigned nb_iterations()
gets the number of performed iterations. the counter is increased each time the function iterate() is...
mainclass to interact with the library. it holds the root of the searchtree.
MCTS(const Context &context, Config *config)
creates a new empty mcts object. only a root node exists.
virtual void backpropagate(const double &value)=0
applies a backpropagation strategy to traverse the simulated result back up in the tree.
basic interface for a node in the tree. Every node has to implement this functions.
ResultType result()
gets the current result node. The node is selected according to a metric defined in a selection strat...
void iterate()
executes one interation step. Each iteration consists of the following actions:
const node_t * root() const
gets the root of the node.
virtual Config * config() const =0
gets the config object
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.
virtual unsigned count_recursive() const
recursively counts number of childen beneth this nodes. counts in the current node.
unsigned nb_nodes()
gets the number of nodes the tree is currently holding.