Beispiel #1
0
        protected MCTSNode Expand(MCTSNode parent, ActionDST action)
        {
            WorldModelDST newState = parent.State.GenerateChildWorldModel();

            action.ApplyActionEffects(newState);

            var child = new MCTSNode(newState)
            {
                Action = action,
                Parent = parent,
            };

            parent.ChildNodes.Add(child);

            return(child);
        }
Beispiel #2
0
        protected float Playout(WorldModelDST initialPlayoutState)
        {
            List <ActionDST> executableActions;
            ActionDST        action = null;
            int           randomIndex;
            WorldModelDST state = initialPlayoutState;

            while (this.CurrentDepth < this.MaxPlayoutDepthReached)
            {
                executableActions = state.GetExecutableActions();

                if (executableActions.Count > 0)
                {
                    this.CurrentDepth++;

                    randomIndex = this.RandomGenerator.Next(0, executableActions.Count);
                    action      = executableActions[randomIndex];
                    state       = state.GenerateChildWorldModel();
                    action.ApplyActionEffects(state);
                }
                else
                {
                    this.CurrentDepth++;
                }
            }

            if (this.CurrentDepth < this.MaxPlayoutDepthReached)
            {
                this.CurrentDepth = this.MaxPlayoutDepthReached;
            }

            //Console.WriteLine("Value Heuristic:");
            //Console.WriteLine(PlayoutHeuristic(state));
            //Console.WriteLine("");

            return(PlayoutHeuristic(state));
        }