Ejemplo n.º 1
0
 public static void ApplyAndValidatePlan(IReGoapGoal <string, object> plan, ReGoapTestMemory memory)
 {
     foreach (var action in plan.GetPlan())
     {
         Assert.That(action.Action.GetPreconditions(plan.GetGoalState()).MissingDifference(memory.GetWorldState(), 1) == 0);
         foreach (var effectsPair in action.Action.GetEffects(plan.GetGoalState()).GetValues())
         {   // in a real game this should be done by memory itself
             //  e.x. isNearTarget = (transform.position - target.position).magnitude < minRangeForCC
             memory.SetValue(effectsPair.Key, effectsPair.Value);
         }
     }
     Assert.That(plan.GetGoalState().MissingDifference(memory.GetWorldState(), 1) == 0);
 }
Ejemplo n.º 2
0
        public static void ApplyAndValidatePlan(IReGoapGoal <string, object> plan, ReGoapTestAgent agent, ReGoapTestMemory memory)
        {
            GoapActionStackData <string, object> stackData;

            stackData.agent        = agent;
            stackData.currentState = memory.GetWorldState();
            stackData.goalState    = plan.GetGoalState();
            stackData.next         = null;
            stackData.settings     = null;
            foreach (var action in plan.GetPlan())
            {
                stackData.settings = action.Settings;
                Assert.That(action.Action.GetPreconditions(stackData).MissingDifference(stackData.currentState, 1) == 0);
                foreach (var effectsPair in action.Action.GetEffects(stackData).GetValues())
                {   // in a real game this should be done by memory itself
                    //  e.x. isNearTarget = (transform.position - target.position).magnitude < minRangeForCC
                    memory.SetValue(effectsPair.Key, effectsPair.Value);
                }
            }
            Assert.That(plan.GetGoalState().MissingDifference(memory.GetWorldState(), 1) == 0);
        }