public bool IsGoalTest(CondPlan plan) { if (plan.ResultStates == null) return IsGoalTest(plan.CurrentPosition); foreach (var gNode in plan.ResultStates.Where(x => !plan.Next.CurrentPosition.Equals(x))) { if (!IsGoalTest(gNode)) return false; } return IsGoalTest(plan.Next); }
public bool IsGoalTest(CondPlan plan) { if (plan.ResultStates == null) { return(IsGoalTest(plan.CurrentPosition)); } foreach (var gNode in plan.ResultStates.Where(x => !plan.Next.CurrentPosition.Equals(x))) { if (!IsGoalTest(gNode)) { return(false); } } return(IsGoalTest(plan.Next)); }
/// <summary> /// this is an example of a <see cref="CondPlan"/> based on Fig. 4.10 /// </summary> public CondPlan Example() { var firstStep = new CondPlan { CurrentPosition = InitState, Action = new Suck(), Next = null, ResultStates = new List<IState> { GetPositionById(7), GetPositionById(5) } }; var secondStep = new CondPlan { CurrentPosition = GetPositionById(5), Action = new Right(), Next = firstStep, ResultStates = new List<IState> { GetPositionById(6) } }; return new CondPlan { CurrentPosition = GetPositionById(6), Action = new Suck(), Next = secondStep, ResultStates = new List<IState> { GetPositionById(8) } }; }