libmcts
A Monte Carlo Tree Search Library
sampling_to_function_selector.hpp
1 #ifndef SAMPLING_TO_FUNCTION_SELECTOR_H
2 #define SAMPLING_TO_FUNCTION_SELECTOR_H
3 
4 #include "sampling_selector.hpp"
5 
6 namespace mcts {
7 
8 // ----------------------------------------------------------------------
14 // ----------------------------------------------------------------------
15 template <typename Context, typename Config>
16 class SamplingToFunctionSelector : public ISelectionStrategy<Context, Config> {
18  typedef typename INode<Context, Config>::node_t node_t;
20 
21 public:
22  // ----------------------------------------------------------------------
28  // ----------------------------------------------------------------------
29  SamplingToFunctionSelector(int threshold_, sstrategy_t *function_strat_)
30  : threshold(threshold_), function_strat(function_strat_),
31  sselector(sampling_selector_t()) {}
32 
33  node_t *select(node_t *node) {
34  return (node->nb_samples() < threshold) ? sselector.select(node)
35  : function_strat->select(node);
36  }
37 
38 protected:
40  int threshold;
41  sstrategy_t *function_strat;
42  sampling_selector_t sselector;
43 };
44 }
45 
46 #endif
SamplingToFunctionSelector(int threshold_, sstrategy_t *function_strat_)
create new selector
node_t * select(node_t *node)
randomly chooses a child of node
selector that chooses random children uniformly
interface for all selection strategies. A selection strategy selects one child of a parent node accor...
basic interface for a node in the tree. Every node has to implement this functions.
Definition: inode.hpp:18
node_t * select(node_t *node)
select a child of node
Uses sampling selector until threshold is reached. After that a supplied selection strategy is applie...
virtual int nb_samples() const =0
number of times a selection strategy selected the current node.
int threshold
number of samples before the strategy is switched.
virtual node_t * select(node_t *node)=0
select a child of node