public void ManageEditor(MovementAIEditor editor)
        {
            AIType      aiType      = (AIType)editor.aiType_Prop.enumValueIndex;
            AIAlgorithm aiAlgorithm = (AIAlgorithm)editor.aiAlgorithm_Prop.enumValueIndex;

            switch (aiAlgorithm)
            {
            case AIAlgorithm.KinematicSeek:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                break;

            case AIAlgorithm.KinematicFlee:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                break;

            case AIAlgorithm.KinematicArrive:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.satisfactionRadius_Prop, new GUIContent("Satisfaction radius"));
                EditorGUILayout.PropertyField(editor.timeToTarget_Prop, new GUIContent("Time to target"));
                break;

            case AIAlgorithm.KinematicWander:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.maxRotation_Prop, new GUIContent("Max rotation"));
                break;
            }
        }
예제 #2
0
        public void ManageEditor(MovementAIEditor editor)
        {
            AIType      aiType      = (AIType)editor.aiType_Prop.enumValueIndex;
            AIAlgorithm aiAlgorithm = (AIAlgorithm)editor.aiAlgorithm_Prop.enumValueIndex;

            switch (aiAlgorithm)
            {
            case AIAlgorithm.DynamicSeek:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.maxAcceleration_Prop, new GUIContent("Max acceleration"));
                break;

            case AIAlgorithm.DynamicFlee:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.maxAcceleration_Prop, new GUIContent("Max acceleration"));
                break;

            case AIAlgorithm.DynamicArrive:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.maxAcceleration_Prop, new GUIContent("Max acceleration"));
                EditorGUILayout.PropertyField(editor.targetRadius_Prop, new GUIContent("Target radius"));
                EditorGUILayout.PropertyField(editor.slowRadius_Prop, new GUIContent("Slow radius"));
                EditorGUILayout.PropertyField(editor.timeToTarget_Prop, new GUIContent("Time to target"));
                break;

            case AIAlgorithm.DynamicAlign:
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.maxRotation_Prop, new GUIContent("Max rotation"));
                EditorGUILayout.PropertyField(editor.maxAngularAcceleration_Prop, new GUIContent("Max angular acceleration"));
                EditorGUILayout.PropertyField(editor.targetRadius_Prop, new GUIContent("Target radius"));
                EditorGUILayout.PropertyField(editor.slowRadius_Prop, new GUIContent("Slow radius"));
                EditorGUILayout.PropertyField(editor.timeToTarget_Prop, new GUIContent("Time to target"));
                break;

            case AIAlgorithm.DynamicVelocityMatch:
                EditorGUILayout.PropertyField(editor.maxSpeed_Prop, new GUIContent("Max speed"));
                EditorGUILayout.PropertyField(editor.target_Prop, new GUIContent("Target"));
                EditorGUILayout.PropertyField(editor.maxAcceleration_Prop, new GUIContent("Max acceleration"));
                EditorGUILayout.PropertyField(editor.timeToTarget_Prop, new GUIContent("Time to target"));
                break;
            }
        }
예제 #3
0
 public int GetMove(Marking[] boardValues)
 {
     System.Threading.Thread.Sleep(1500);
     return(AIAlgorithm.GetMove(boardValues, Marking));
 }
예제 #4
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));
        }
예제 #5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(aiType_Prop, new GUIContent("AI Type"));


            string selectedAIType = Enum.GetNames(AIType.None.GetType())[aiType_Prop.enumValueIndex];
            LinkedList <string> algorithmsOptionsList = new LinkedList <string>();

            string[] algorithmsNames = Enum.GetNames(AIAlgorithm.KinematicNone.GetType());
            foreach (string algName in algorithmsNames)
            {
                if (algName.Contains(selectedAIType))
                {
                    algorithmsOptionsList.AddLast(algName);
                }
            }
            string[] algorithmsOptionsArray = new string[algorithmsOptionsList.Count];
            algorithmsOptionsList.CopyTo(algorithmsOptionsArray, 0);
            int previouslySelectedIndex = 0;

            for (int i = 0; i < algorithmsOptionsArray.Length; i++)
            {
                if (algorithmsOptionsArray[i].Equals(algorithmsNames[aiAlgorithm_Prop.enumValueIndex]))
                {
                    previouslySelectedIndex = i;
                }
            }
            int newSelectedIndex             = algorithmsOptionsArray.Length - 1 < previouslySelectedIndex ? algorithmsOptionsArray.Length - 1 : previouslySelectedIndex;
            int algorithmChosenRelativeIndex = EditorGUILayout.Popup("AI Algorithm", newSelectedIndex, algorithmsOptionsArray);

            previouslySelectedIndex = algorithmChosenRelativeIndex;
            string algorithmChosenName          = algorithmsOptionsArray[algorithmChosenRelativeIndex];
            int    algorithmChosenAbsoluteIndex = 0;

            for (int i = 0; i < algorithmsNames.Length; i++)
            {
                if (algorithmsNames[i].Equals(algorithmChosenName))
                {
                    algorithmChosenAbsoluteIndex = i;
                }
            }
            aiAlgorithm_Prop.enumValueIndex = algorithmChosenAbsoluteIndex;

            AIType      aiType      = (AIType)aiType_Prop.enumValueIndex;
            AIAlgorithm aiAlgorithm = (AIAlgorithm)aiAlgorithm_Prop.enumValueIndex;

            //Debug.Log("AIType: " + aiType);
            //Debug.Log("AIAlgorithm: " + aiAlgorithm);

            EditorGUILayout.PropertyField(lookWhereYoureGoing_Prop, new GUIContent("Always look ahead"));

            AlgorithmsManager manager = new KinematicAlgorithmsManager();             // Default

            switch (aiType)
            {
            case AIType.Dynamic:
                manager = new DynamicAlgorithmsManager();
                break;

            case AIType.Kinematic:
                manager = new KinematicAlgorithmsManager();
                break;

            case AIType.None:
                if (aiAlgorithm == AIAlgorithm.KinematicNone)
                {
                    manager = new KinematicAlgorithmsManager();
                }
                else if (aiAlgorithm == AIAlgorithm.DynamicNone)
                {
                    manager = new DynamicAlgorithmsManager();
                }
                break;
            }
            manager.ManageEditor(this);

            serializedObject.ApplyModifiedProperties();
        }