Exemplo n.º 1
0
        protected float Playout(WorldModelDST initialPlayoutState)
        {
            List <ActionDST> actions;

            WorldModelDST clone = initialPlayoutState.GenerateChildWorldModel();

            CurrentDepth = 0;
            //int parentID = 0; // ?
            int size = 0, random = 0;

            while (CurrentDepth < MaxPlayoutDepthReached)
            {
                actions = clone.GetExecutableActions();
                foreach (var a in actions)
                {
                    //Console.WriteLine(a);
                }

                size = actions.Count;
                //Console.WriteLine("size:" + size);

                random = this.RandomGenerator.Next(0, size - 1);
                actions[random].ApplyActionEffects(clone);

                //Had clone.getNextPlayer here in proj algorithm
                CurrentDepth++;
            }
            //return score
            return(initialPlayoutState.Score());
        }
Exemplo n.º 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));
        }