4#include "bitrl/base/bitrl_config.h"
176template <
typename ActionTp,
typename StateTp>
184template <
typename ActionTp,
typename StateTp>
190 assert(child !=
nullptr &&
"Cannot add null children");
196template <
typename ActionTp,
typename StateTp>
197template <
typename RandomEngine>
209template <
typename ActionTp,
typename StateTp>
217template <
typename ActionTp,
typename StateTp>
218std::shared_ptr<MCTSNodeBase<ActionTp, StateTp>>
224 return std::shared_ptr<MCTSNodeBase>();
227 auto current_ucb =
children_[0]->ucb(temperature);
228 auto current_idx = 0;
233 auto node_ucb = node->ucb(temperature);
235 if (node_ucb > current_ucb)
238 current_idx = dummy_idx;
239 current_ucb = node_ucb;
248template <
typename ActionTp,
typename StateTp>
254 return std::numeric_limits<real_t>::max();
264 temperature * std::sqrt(std::log(
static_cast<real_t>(
parent_->total_visits())) /
action_type action_type
Definition mcts_node.h:33
void add_child(std::shared_ptr< MCTSNodeBase< ActionTp, StateTp > > child)
add_child
Definition mcts_node.h:185
std::shared_ptr< MCTSNodeBase > parent()
Definition mcts_node.h:142
uint_t total_visits_
Definition mcts_node.h:153
std::shared_ptr< MCTSNodeBase > get_child(uint_t cidx) const
get_child
Definition mcts_node.h:72
uint_t total_visits() const noexcept
total_visits
Definition mcts_node.h:130
MCTSNodeBase(std::shared_ptr< MCTSNodeBase > parent, action_type action)
MCTreeNodeBase.
Definition mcts_node.h:177
bool has_children() const noexcept
has_children
Definition mcts_node.h:65
std::shared_ptr< MCTSNodeBase > max_ucb_child(real_t temperature) const
max_ucb_child
Definition mcts_node.h:219
void update_visits() noexcept
update_visits
Definition mcts_node.h:94
real_t win_pct() const
win_pct
Definition mcts_node.h:124
std::shared_ptr< MCTSNodeBase > parent_
Definition mcts_node.h:168
virtual ~MCTSNodeBase()=default
real_t ucb(real_t temperature) const
ucb
Definition mcts_node.h:249
real_t total_score_
Definition mcts_node.h:148
action_type get_action() const noexcept
get_action
Definition mcts_node.h:136
uint_t n_children() const noexcept
n_children
Definition mcts_node.h:78
uint_t explored_children_
Definition mcts_node.h:158
uint_t n_explored_children() const noexcept
explored_children
Definition mcts_node.h:89
void shuffle_children(RandomEngine &engine)
shuffle_children
Definition mcts_node.h:198
void add_child(std::shared_ptr< MCTSNodeBase< ActionTp, StateTp > > parent, action_type action)
add_child
Definition mcts_node.h:210
std::vector< std::shared_ptr< MCTSNodeBase > > children_
Definition mcts_node.h:173
state_type state_type
Definition mcts_node.h:34
action_type action_
Definition mcts_node.h:163
void update_total_score(real_t score) noexcept
update_total_score
Definition mcts_node.h:105
void update_explored_children() noexcept
Definition mcts_node.h:99
Definition first_visit_mc.h:27
Definition dp_algo_base.h:15
Definition dummy_agent.h:9
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20