예제 #1
0
        public IEnumerable <string> GetMacromanagementStuff()
        {
            Current_Tree = new MCTSAlgorithm(Owned_Agent.GetDeepCopy(), Enemy_Agent.GetDeepCopy());

            foreach (var result in Current_Tree.GeneratePredictedAction(Owned_Agent.Created_Time.AddSeconds(15)))
            {
                if (result == null)
                {
                    yield return("SURRENDER");

                    break;
                }

                yield return(result.Item1);
            }
        }
예제 #2
0
        public IEnumerable <IEnumerable <double> > GetMacromanagementAccuracyReport(int number_of_simulations, AIAlgorithm algorithm)
        {
            var pomdp_results = new List <List <CostWorth> >();
            var mcts_results  = new List <List <CostWorth> >();

            switch (algorithm)
            {
            case AIAlgorithm.POMDP:
                Current_Tree = new POMDPAlgorithm(Owned_Agent.GetDeepCopy(), Enemy_Agent.GetDeepCopy());
                break;

            case AIAlgorithm.MCTS:
                Current_Tree = new MCTSAlgorithm(Owned_Agent.GetDeepCopy(), Enemy_Agent.GetDeepCopy());
                break;
            }

            try
            {
                for (int simulated = 0; simulated < number_of_simulations; simulated++)
                {
                    mcts_results.Add(new List <CostWorth>());

                    DateTime end;
                    if (Owned_Agent.EndTime > Enemy_Agent.EndTime)
                    {
                        end = Owned_Agent.EndTime;
                    }
                    else
                    {
                        end = Enemy_Agent.EndTime;
                    }

                    foreach (var result in Current_Tree.GeneratePredictedAction(end))
                    {
                        if (result == null)
                        {
                            break;
                        }
                        mcts_results[0].Add(result.Item2);
                    }
                }
            }
            catch (ArgumentException ex)
            {
            }

            var random = Services.ModelRepositoryService.ModelService.GetModelService();

            //Perform Euclidean Operations
            try
            {
                var enemy_basis = String.Join(",", Enemy_Agent.Basis.Select(basis => Convert.ToDouble(basis.Item3)));
            }
            catch (ArgumentNullException ex)
            {
            }



            string owned_basis        = String.Join(",", Owned_Agent.Basis.Select(basis => Convert.ToDouble(basis.Item3)).Take(5));
            var    owned_results_mcts = mcts_results.Select(result => String.Join(",", result.Select(costworth => Convert.ToDouble(costworth)))).Take(5);

            yield return(random.GetEuclideanMetric(owned_basis, owned_results_mcts));
        }