Answers.Body: <p>Assigning a value of <span class="math-container">$\infty$</span> to unvisited nodes is indeed the &quot;default&quot; or most basic choice, and it indeed ensures that the search never visits a node for a second time if it also still has siblings that have not had any visits. But many other kinds of values have been tried in the literature too.</p>
  <p>Gelly and Wang, in <a href="https://hal.archives-ouvertes.fr/hal-00115330/en/" rel="nofollow noreferrer">&quot;Exploration exploitation in Go: UCT for Monte-Carlo Go&quot;</a> referred to the parameter as &quot;First-play Urgency&quot; (FPU), and indeed really treated it as a hyperparameter; they simply tried various different values and some were found to work better than others.</p>
  <p>Other more specific values that you may want to consider (but in most cases we can't really say much about which one will be better than which other ones, without empirical evaluations) are:</p>
  <ul>
  <li>The value of a loss; treating nodes that have not had any visits as losing nodes is probably the most &quot;pessimistic&quot; initialisation you could pick. It's not very clearly described in the papers, but there is some evidence out there that this was used by AlphaGo Zero and AlphaZero. Those are not simply vanilla UCTs though, those programs had very strong trained Deep Neural Networks to make additional recommendations for actions. If you don't have such strong neural networks to introduce additional biases in your selection, I would not recommend treating unvisited nodes as losing nodes.</li>
  <li>The value of a draw; treating unvisited nodes as draws means that you may prioritise re-visiting nodes that look like winning nodes, but you won't prioritise re-visiting nodes that look like losing nodes.</li>
  <li>The value of a win; this probably produces similar behaviour in practice as a value of <span class="math-container">$\infty$</span></li>
  <li>The average value backpropagated into the parent (correcting for differences in player-colour-to-move); you may prioritise re-visiting nodes that perform better than average in this subtree, but won't prioritise re-visiting nodes that perform worse than average in this subtree</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-02T08:27:51.840Z
Answers.Text: Thank you Dennis for your thorough answer!
  Similarly to your third suggestion, I have experimented with setting each node's sim_count = 2 and win_count = 2, as the evaluation is comparative anyway. For my implementation this also means the easiest change.
Answers.UserDisplayName: semyd
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-31T15:54:32.027Z
Answers.LastActivityDate: 2021-01-31T16:07:39.703Z
Answers.LastEditDate: 2021-01-31T16:07:39.703Z
Answers.UserDisplayName: Dennis Soemers
Body: <p>I am implenting a Monte Carlo Tree Search algorithm, where the selection process is done through Upper Confidence Bound formula:</p>
  <pre><code>def uct(state):
          log_n = math.log(state.parent.sim_count) 
          explore_term = self.exploration_weight * math.sqrt(log_n / state.sim_count)
          exploit_term = (state.win_count / state.sim_count)
  
          return exploit_term + explore_term
  </code></pre>
  <p>I have trouble however choosing the initial value for UCT, when the sim_count of the node is 0. I tried with +inf (which would be appropriate as approaching lim -&gt; 0 from the positive side would give infinity), but that just means the algorithm will be always choosing an unexplored child.</p>
  <p>What would you suggest as a initial value for the uct?</p>
  <p>Thank you in advance!</p>
  
Tags: <monte-carlo-tree-search><upper-confidence-bound><tree-search>
Title: What should the initial UCT value be with MCTS, when leaf's simulation count is zero? Infinity?
UserDisplayName: semyd
ThreadText: # What should the initial UCT value be with MCTS, when leaf's simulation count is zero? Infinity?
  
  (Asked by: username_0 on 2021-01-24)
  
  I am implenting a Monte Carlo Tree Search algorithm, where the selection process is done through Upper Confidence Bound formula:
  
  ```
  def uct(state):
          log_n = math.log(state.parent.sim_count) 
          explore_term = self.exploration_weight * math.sqrt(log_n / state.sim_count)
          exploit_term = (state.win_count / state.sim_count)
  
          return exploit_term + explore_term
  
  ```
  
  I have trouble however choosing the initial value for UCT, when the sim\_count of the node is 0. I tried with +inf (which would be appropriate as approaching lim -> 0 from the positive side would give infinity), but that just means the algorithm will be always choosing an unexplored child.
  
  What would you suggest as a initial value for the uct?
  
  Thank you in advance!
  
  **Tags:** monte-carlo-tree-search, upper-confidence-bound, tree-search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-31. Score: 1 | Accepted answer
  
  Assigning a value of $\infty$ to unvisited nodes is indeed the "default" or most basic choice, and it indeed ensures that the search never visits a node for a second time if it also still has siblings that have not had any visits. But many other kinds of values have been tried in the literature too.
  
  Gelly and Wang, in ["Exploration exploitation in Go: UCT for Monte-Carlo Go"](https://hal.archives-ouvertes.fr/hal-00115330/en/) referred to the parameter as "First-play Urgency" (FPU), and indeed really treated it as a hyperparameter; they simply tried various different values and some were found to work better than others.
  
  Other more specific values that you may want to consider (but in most cases we can't really say much about which one will be better than which other ones, without empirical evaluations) are:
  
  * The value of a loss; treating nodes that have not had any visits as losing nodes is probably the most "pessimistic" initialisation you could pick. It's not very clearly described in the papers, but there is some evidence out there that this was used by AlphaGo Zero and AlphaZero. Those are not simply vanilla UCTs though, those programs had very strong trained Deep Neural Networks to make additional recommendations for actions. If you don't have such strong neural networks to introduce additional biases in your selection, I would not recommend treating unvisited nodes as losing nodes.
  * The value of a draw; treating unvisited nodes as draws means that you may prioritise re-visiting nodes that look like winning nodes, but you won't prioritise re-visiting nodes that look like losing nodes.
  * The value of a win; this probably produces similar behaviour in practice as a value of $\infty$
  * The average value backpropagated into the parent (correcting for differences in player-colour-to-move); you may prioritise re-visiting nodes that perform better than average in this subtree, but won't prioritise re-visiting nodes that perform worse than average in this subtree
  
  > **Comments:**
  > **username_0**: Thank you username_1 for your thorough answer! Similarly to your third suggestion, I have experimented with setting each node's sim_count = 2 and win_count = 2, as the evaluation is comparative anyway. For my implementation this also means the easiest change.  
  
  ---
  
  