コード例 #1
0
        private float Simulation(Node nodeToSimulate, POGame poGame)
        {
            float      result          = -1;
            int        simulationSteps = 0;
            PlayerTask task            = null;

            List <PlayerTask> taskToSimulate = new List <PlayerTask>();

            if (poGame == null)
            {
                return(0.5f);
            }

            if (nodeToSimulate.task.PlayerTaskType == PlayerTaskType.END_TURN)
            {
                return(Estimator.estimateFromState(ESTIMATION_MODE, poGame));
            }

            while (poGame.getGame().State != SabberStoneCore.Enums.State.COMPLETE)
            {
                task = SimulationPolicies.selectSimulationPolicy(SIMULATION_POLICY, poGame, Rnd, greedyAgent, CHILDREN_CONSIDERED_SIMULATING);
                taskToSimulate.Add(task);
                if (task.PlayerTaskType != PlayerTaskType.END_TURN)
                {
                    poGame = poGame.Simulate(taskToSimulate)[taskToSimulate[0]];
                }

                taskToSimulate.Clear();

                if (poGame == null)
                {
                    return(0.5f);
                }

                if (task.PlayerTaskType == PlayerTaskType.END_TURN)
                {
                    return(Estimator.estimateFromState(ESTIMATION_MODE, poGame));
                }

                simulationSteps++;
            }


            if (poGame.CurrentPlayer.PlayState == SabberStoneCore.Enums.PlayState.CONCEDED ||
                poGame.CurrentPlayer.PlayState == SabberStoneCore.Enums.PlayState.LOST)
            {
                result = 0;
            }
            else if (poGame.CurrentPlayer.PlayState == SabberStoneCore.Enums.PlayState.WON)
            {
                result = 1;
            }

            return(result);
        }