6 #include "ivisitor.hpp" 18 template <
typename Context,
typename Config>
class INode {
59 virtual Config *
config()
const = 0;
74 virtual const vector<node_t *>
children()
const = 0;
88 virtual const Context
context()
const = 0;
95 virtual double ev()
const = 0;
102 virtual double std_dev()
const = 0;
109 virtual double variance()
const = 0;
116 virtual double simulate()
const = 0;
142 for (
unsigned i = 0; i <
children.size(); ++i) {
143 sum +=
children[i]->count_recursive();
virtual node_t * select_child()=0
selects a childnode according to a configurable metric
virtual void expand()=0
expand the current context and add all possible derived contexts as children.
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.
virtual void accept(visitor_t *visitor)=0
accepts a visitor according to the visitor pattern.
virtual double std_dev() const =0
gets the standard deviation.
virtual node_t * parent() const =0
gets the parent of the current node
virtual Config * config() const =0
gets the config object
virtual const Context context() const =0
gets the context associated with the current node
virtual double variance() const =0
gets the variance.
virtual int nb_samples() const =0
number of times a selection strategy selected the current node.
virtual double simulate() const =0
applies a simulation strategy to a terminal node.
implements interface for visitor objects.
virtual const vector< node_t * > children() const =0
get the children of the current node
virtual double ev() const =0
gets the current expected value.
virtual void add_child(node_t *child)=0
insert a new node as a child of the current one.
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.