Пример #1
0
 /// <summary>
 /// Every new MCTS iteration entry point, finds the best leaf according to the UCT
 /// </summary>
 protected virtual void Traverse()
 {
     if (IsLeaf())
     {
         if (visits == 0)
         {
             Backpropagate(Rollout());
         }
         else
         {
             Expand();
             if (children.Count == 0)
             {
                 Backpropagate(state.GetScores());
             }
             else
             {
                 Backpropagate(children[0].Rollout());
             }
         }
     }
     else
     {
         this.pickBestChild(explorationConstant).Traverse();
     }
 }
Пример #2
0
        /// <summary>
        /// Performs an uninformed rollout (random simulation till the end of the game)
        /// </summary>
        /// <returns>The scores at the end of the simulated game</returns>
        protected virtual Dictionary <string, double> Rollout()
        {
            ISimulationState randomChild, currentState = this.state;

            while ((randomChild = currentState.RandomChild()) != null)
            {
                currentState = randomChild;
            }
            return(currentState.GetScores());
        }