private void BuildPlanHandler() { // Create planner. var planner = new AntAIPlanner(); // planner.DebugMode = true; planner.LoadScenario(_scenario); // Create current world state and set current conditions. var current = new AntAICondition(); current.BeginUpdate(planner); for (int i = 0, n = _worldState.list.Length; i < n; i++) { current.Set(_scenario.conditions.GetName(_worldState.list[i].id), _worldState.list[i].value); } current.EndUpdate(); // Create our goal world state. AntAIScenarioGoal defaultGoal = null; for (int i = 0, n = _scenario.goals.Length; i < n; i++) { if (_scenario.goals[i].isDefault) { defaultGoal = _scenario.goals[i]; break; } } A.Assert(defaultGoal == null, "Default goal not found!"); if (defaultGoal == null) { return; } // Copy conditions from the scenario goal to the goal conditions. var goal = new AntAICondition(); goal.BeginUpdate(planner); for (int i = 0, n = defaultGoal.conditions.Length; i < n; i++) { goal.Set(_scenario.conditions.GetName(defaultGoal.conditions[i].id), defaultGoal.conditions[i].value); } goal.EndUpdate(); // Create and build the plan. var plan = new AntAIPlan(); planner.MakePlan(ref plan, current, goal); // Call event when plan is ready. if (EventBuildPlan != null) { EventBuildPlan(this, plan, planner); } }
public AntAICondition defaultGoal; // Цель по умолчанию. public AntAIAgent() { sense = null; currentState = null; defaultState = null; worldState = new AntAICondition(); planner = new AntAIPlanner(); currentPlan = new AntAIPlan(); currentGoal = null; }
public bool OverlapInterrupts(AntAIPlanner aPlanner, AntAICondition aConditions) { int index = -1; for (int i = 0, n = _interruptions.Count; i < n; i++) { index = aPlanner.GetAtomIndex(_interruptions[i]); if (aConditions.GetValue(index)) { return(true); } } return(false); }
public void BindData(string aTitle, AntAIPlanner aPlanner, AntAICondition aCur, AntAICondition aPre) { title = string.Concat("▶ ", aTitle); _items = new List <Item>(); bool v; for (int i = 0, n = AntAIPlanner.MAX_ATOMS; i < n; i++) { if (aCur.GetMask(i)) { v = aCur.GetValue(i); _items.Add(new Item { name = aPlanner.atoms[i], value = v, isChanged = (v != aPre.GetValue(i)) }); } } }