// Called when planning, to simulate the effects of the action to the world public override StateList Simulate(StateList world) { StateList applied = world.Copy(); postconditions.SaveCache(); // check each property in the state, and change it from precondition to postcondition foreach (State postcondition in postconditions.states) { applied.SetState(postcondition.Name, postcondition.Value); } return(applied); }
public void StateMatchingMissingInfo() { // Test a match failure of a world that doesn't have info our goal needs // Populate our world - no ammo StateList world = new StateList(); world.SetState("health", 10.0f); world.SetState("locationX", 15.0f); world.SetState("locationY", -35.0f); // our goal only cares about location and ammo StateList goal = new StateList(); goal.SetState("ammo", 40.0f); goal.SetState("locationX", 15.0f); goal.SetState("locationY", -35.0f); goal.SaveCache(); // We can't match info we don't have Assert.False(world.Matches(goal)); }