Пример #1
0
        public bool ConditionsMet()
        {
            bool conditionsMet = state.GetPreconditions().Count == 0;

            if (!conditionsMet)
            {
                conditionsMet = true;
                foreach (var precondition in state.GetPreconditions())
                {
                    if (!agent.GetMemory().ConditionMet(precondition.Key, precondition.Value))
                    {
                        conditionsMet = false;
                        break;
                    }
                }
            }

            return(conditionsMet);
        }
Пример #2
0
        public AINode(AIAgent agent, AIPlanner planner, AIAction action = null, AINode parent = null)
        {
            this.agent   = agent;
            this.planner = planner;
            this.action  = action;
            this.parent  = parent;

            if (action == null)
            {
                // This is a goal node
                state = new AIState(planner.GetGoal(), agent.GetMemory().CloneState());
                state.AddUnmetPreconditions(planner.GetGoal().GetConditions());
                g = 0;
            }
            else
            {
                // Initialise Action node
                state = new AIState();
                g     = float.MaxValue;
            }
        }