예제 #1
0
        // Remember that goal must not be achieved before considering traversal
        public bool DoSkip(List <Goal> goals, Dictionary <string, object> entityValues, List <Response> responses)
        {
            List <Goal> activeAndAchievedSubgoals = new List <Goal>();

            // Finds all active and achieved children
            foreach (Goal goal in goals)
            {
                if (SubgoalIDs.Contains(goal.ID))
                {
                    if (goal.IsActive(entityValues))
                    {
                        if (goal.IsAchieved(goals, entityValues, responses))
                        {
                            activeAndAchievedSubgoals.Add(goal);
                        }
                    }
                }
            }

            // Composite goal has been partially achieved, so skip.
            if (activeAndAchievedSubgoals.Count > 0)
            {
                return(true);
            }
            else
            {
                return(TrySkip); // Composite goal is allowed to skip, so leave decision up to TrySkip preference
            }
        }
예제 #2
0
        public override bool IsAchieved(List <Goal> goals, Dictionary <string, object> entityValues, List <Response> responses)
        {
            List <Goal> activeSubgoals            = new List <Goal>();
            List <Goal> activeAndAchievedSubgoals = new List <Goal>();

            // Finds all achieved children
            foreach (Goal goal in goals)
            {
                if (SubgoalIDs.Contains(goal.ID))
                {
                    if (goal.IsActive(entityValues))
                    {
                        activeSubgoals.Add(goal);

                        if (goal.IsAchieved(goals, entityValues, responses))
                        {
                            activeAndAchievedSubgoals.Add(goal);
                        }
                    }
                }
            }

            return(activeSubgoals.Count == activeAndAchievedSubgoals.Count); // Achieved if all active subgoals are achieved
        }