src/mcts.cpp
// Assumes there is at least one child
// Assumes visits_ is > 0
Assumes there is at least one child
Assumes visits_ is > 0
Assumes there is at least one child Assumes visits_ is > 0
MCTSNode *MCTSNode::UCTSelectChild(void) const {
  double log_parent_visits = log(visits_);
  MCTSNode *best_child = children_[0];
  double best_score = best_child->UCTScore(log_parent_visits);
  int num_children = children_.size();
  for (int i = 1; i < num_children; ++i) {
    MCTSNode *child = children_[i];
    double score = child->UCTScore(log_parent_visits);
    if (score > best_score) {
      best_score = score;
      best_child = child;
    }
  }
  return best_child;
}
MCTSNode * MCTSNode :: UCTSelectChild ( void ) const { double log_parent_visits = log ( visits_ ) ; MCTSNode * best_child = children_ [ 0 ] ; double best_score = best_child -> UCTScore ( log_parent_visits ) ; int num_children = children_ . size ( ) ; for ( int i = 1 ; i < num_children ; ++ i ) { MCTSNode * child = children_ [ i ] ; double score = child -> UCTScore ( log_parent_visits ) ; if ( score > best_score ) { best_score = score ; best_child = child ; } } return best_child ; }
Assumes there is at least one child
Assumes visits_ is > 0
Assumes there is at least one child Assumes visits_ is > 0