Example #1
0
        public void GoToMushroomTest()
        {
            GameObject                  testGameObject = new GameObject();
            Agent <string, bool>        agent          = testGameObject.AddComponent <StringBoolAgent>();
            SortableGoal <string, bool> goal           = new SortableGoal <string, bool> {
                { "AtTargetPosition", true }, { "TargetIsMushroom", true }
            };

            goal.Priority = 1;

            agent.AddGoal(goal);
            agent.SetWorkingMemory(new WorldState <string, bool> {
            });

            agent.AddAction(new ExecutableAction <string, bool>(_label: "LookForMushroom",
                                                                _preconditions: new WorldStateModifier <string, bool> {
            },
                                                                _effects: new WorldStateModifier <string, bool> {
                { "HasTargetPosition", true }, { "AtTargetPosition", false }, { "TargetIsMushroom", true }
            },
                                                                _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, bool>(_label: "MoveToPosition",
                                                                _preconditions: new WorldStateModifier <string, bool> {
                { "HasTargetPosition", true }, { "AtTargetPosition", false }
            },
                                                                _effects: new WorldStateModifier <string, bool> {
                { "HasTargetPosition", false }, { "AtTargetPosition", true }
            },
                                                                _baseUtility: 5.0f));

            GoalPlanPair <string, bool> generatedGoalPlanPair = m_StringBoolPlanner.GenerateGoalPlanPairForAgent(agent);

            Assert.True(generatedGoalPlanPair.PlanInstance.Count == 2);
            Assert.AreEqual("LookForMushroom", generatedGoalPlanPair.PlanInstance.Pop().GetLabel());
            Assert.AreEqual("MoveToPosition", generatedGoalPlanPair.PlanInstance.Pop().GetLabel());
        }
Example #2
0
        public void MushroomGathererStringObjectPerformance()
        {
            GameObject                    testGameObject = new GameObject();
            Agent <string, object>        agent          = testGameObject.AddComponent <StringObjectAgent>();
            SortableGoal <string, object> goal           = new SortableGoal <string, object> {
                { "HasEnoughMushrooms", true }
            };

            goal.Priority = 1;

            agent.AddGoal(goal);
            agent.SetWorkingMemory(new WorldState <string, object> {
            });

            agent.AddAction(new ExecutableAction <string, object>(_label: "LookForMushroom",
                                                                  _preconditions: new WorldStateModifier <string, object> {
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "HasTargetPosition", true }, { "AtTargetPosition", false }, { "TargetIs", "Mushroom" }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "PickupMushroom",
                                                                  _preconditions: new WorldStateModifier <string, object> {
                { "AtTargetPosition", true }, { "TargetIs", "Mushroom" }
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "CarriesMushroom", true }, { "HasTargetPosition", true }, { "AtTargetPosition", false }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "MoveToPosition",
                                                                  _preconditions: new WorldStateModifier <string, object> {
                { "HasTargetPosition", true }, { "AtTargetPosition", false }
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "HasTargetPosition", false }, { "AtTargetPosition", true }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "DropOffMushroomAtHome",
                                                                  _preconditions: new WorldStateModifier <string, object> {
                { "CarriesMushroom", true }, { "AtTargetPosition", true }
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "AtTargetPosition", false }, { "HasEnoughMushrooms", true }, { "CarriesMushroom", false }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "LookForFish",
                                                                  _preconditions: new WorldStateModifier <string, object> {
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "HasTargetPosition", true }, { "AtTargetPosition", false }, { "TargetIs", "Fish" }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "PickupFish",
                                                                  _preconditions: new WorldStateModifier <string, object> {
                { "AtTargetPosition", true }, { "TargetIs", "Fish" }
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "CarriesFish", true }, { "HasTargetPosition", true }, { "AtTargetPosition", false }
            },
                                                                  _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <string, object>(_label: "DropOffFishAtHome",
                                                                  _preconditions: new WorldStateModifier <string, object> {
                { "CarriesFish", true }, { "AtTargetPosition", true }
            },
                                                                  _effects: new WorldStateModifier <string, object> {
                { "AtTargetPosition", false }, { "HasEnoughFish", true }, { "CarriesFish", false }
            },
                                                                  _baseUtility: 5.0f));

            GoalPlanPair <string, object> generatedGoalPlanPair = m_StringObjectPlanner.GenerateGoalPlanPairForAgent(agent);

            Assert.True(generatedGoalPlanPair.PlanInstance.Count == 5);
        }
Example #3
0
        public void MushroomGathererEnumObjectPerformance()
        {
            GameObject testGameObject = new GameObject();
            Agent <GathererKeys, object>        agent = testGameObject.AddComponent <EnumObjectAgent>();
            SortableGoal <GathererKeys, object> goal  = new SortableGoal <GathererKeys, object> {
                { GathererKeys.HAS_ENOUGH_MUSHROOMS, true }
            };

            goal.Priority = 1;

            agent.AddGoal(goal);
            agent.SetWorkingMemory(new WorldState <GathererKeys, object> {
            });

            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "LookForMushroom",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.HAS_TARGET_POSITION, true }, { GathererKeys.AT_TARGET_POSITION, false }, { GathererKeys.TARGET_IS, "Mushroom" }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "PickupMushroom",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.AT_TARGET_POSITION, true }, { GathererKeys.TARGET_IS, "Mushroom" }
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.CARRIES_MUSHROOM, true }, { GathererKeys.HAS_TARGET_POSITION, true }, { GathererKeys.AT_TARGET_POSITION, false }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "MoveToPosition",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.HAS_TARGET_POSITION, true }, { GathererKeys.AT_TARGET_POSITION, false }
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.HAS_TARGET_POSITION, false }, { GathererKeys.AT_TARGET_POSITION, true }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "DropOffMushroomAtHome",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.CARRIES_MUSHROOM, true }, { GathererKeys.AT_TARGET_POSITION, true }
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.AT_TARGET_POSITION, false }, { GathererKeys.HAS_ENOUGH_MUSHROOMS, true }, { GathererKeys.CARRIES_MUSHROOM, false }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "LookForFish",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.HAS_TARGET_POSITION, true }, { GathererKeys.AT_TARGET_POSITION, false }, { GathererKeys.TARGET_IS, "Fish" }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "PickupFish",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.AT_TARGET_POSITION, true }, { GathererKeys.TARGET_IS, "Fish" }
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.CARRIES_FISH, true }, { GathererKeys.HAS_TARGET_POSITION, true }, { GathererKeys.AT_TARGET_POSITION, false }
            },
                                                                        _baseUtility: 5.0f));
            agent.AddAction(new ExecutableAction <GathererKeys, object>(_label: "DropOffFishAtHome",
                                                                        _preconditions: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.CARRIES_FISH, true }, { GathererKeys.AT_TARGET_POSITION, true }
            },
                                                                        _effects: new WorldStateModifier <GathererKeys, object> {
                { GathererKeys.AT_TARGET_POSITION, false }, { GathererKeys.HAS_ENOUGH_FISH, true }, { GathererKeys.CARRIES_FISH, false }
            },
                                                                        _baseUtility: 5.0f));

            GoalPlanPair <GathererKeys, object> generatedGoalPlanPair = m_EnumObjectPlanner.GenerateGoalPlanPairForAgent(agent);

            Assert.True(generatedGoalPlanPair.PlanInstance.Count == 5);
        }