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

selector that selects the childnode, that maximises the ratio between samples and ev of the parent node. More...

#include <uct_selector.hpp>

Inheritance diagram for mcts::UCTSelector< Context, Config >:
mcts::MaxFunctionSelector< Context, Config > mcts::ISelectionStrategy< Context, Config >

Public Member Functions

 UCTSelector (double _C)
 constructs a new selector More...
 
double evaluate (node_t *node) const
 this function has to be implemented in derived classes that specializes the metric to be used. every child is evaluated against this method. More...
 
- Public Member Functions inherited from mcts::MaxFunctionSelector< Context, Config >
node_tselect (node_t *node)
 select a child of node More...
 

Additional Inherited Members

- Public Types inherited from mcts::ISelectionStrategy< Context, Config >
typedef ISelectionStrategy< Context, Config > sstrategy_t
 

Detailed Description

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

selector that selects the childnode, that maximises the ratio between samples and ev of the parent node.

Template Parameters
Context@README
Config@README

Definition at line 18 of file uct_selector.hpp.

Constructor & Destructor Documentation

◆ UCTSelector()

template<typename Context , typename Config >
mcts::UCTSelector< Context, Config >::UCTSelector ( double  _C)
inline

constructs a new selector

Parameters
_CExploration vs Exploitation small C = tree will be expanded deeper, the best node will be evaluated often. big C = the tree will be expanded wider.More nodes in one level will be evaluated.

Definition at line 35 of file uct_selector.hpp.

35 : C(_C) {}

Member Function Documentation

◆ evaluate()

template<typename Context , typename Config >
double mcts::UCTSelector< Context, Config >::evaluate ( node_t node) const
inlinevirtual

this function has to be implemented in derived classes that specializes the metric to be used. every child is evaluated against this method.

Parameters
nodeto evaluate
Returns
number representing some metric.

Implements mcts::MaxFunctionSelector< Context, Config >.

Definition at line 37 of file uct_selector.hpp.

37  {
38  int nb_samples = node->nb_samples();
39  if (nb_samples == 0)
40  return 0;
41 
42  int nb_parent_samples = node->parent()->nb_samples();
43  return node->ev() + C * sqrt(log((double)nb_parent_samples) / nb_samples);
44  }

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