public bool Has(AntAIPlanner aPlanner, string aAtomName) { int index = aPlanner.GetAtomIndex(aAtomName); return((index >= 0 && index < values.Length) ? values[index] : false); }
private void Start() { // 1. Create the AI planner. // ------------------------- var planner = new AntAIPlanner(); // Load scenario for planner. A.Assert(scenario == null, "Scenario not selected!"); planner.LoadScenario(scenario); // 2. Create world state. // ---------------------- var worldState = new AntAICondition(); worldState.BeginUpdate(planner); worldState.Set("Is Cargo Delivered", false); worldState.Set("See Cargo", false); worldState.Set("Has Cargo", false); worldState.Set("See Base", false); worldState.Set("Near Base", false); worldState.EndUpdate(); // 3. Build plan. // -------------- var plan = new AntAIPlan(); planner.MakePlan(ref plan, worldState, planner.GetDefaultGoal()); // Output plan. Debug.Log("<b>Plan:</b>"); for (int i = 0; i < plan.Count; i++) { Debug.Log((i + 1) + ". " + plan[i]); } // 4. Change world state and rebuild plan. // --------------------------------------- worldState.BeginUpdate(planner); worldState.Set("Has Cargo", true); worldState.EndUpdate(); planner.MakePlan(ref plan, worldState, planner.FindGoal("Delivery")); // Output plan. Debug.Log("<b>Plan:</b>"); for (int i = 0; i < plan.Count; i++) { Debug.Log((i + 1) + ". " + plan[i]); } }
public bool Set(AntAIPlanner aPlanner, string aAtomName, bool aValue) { return(Set(aPlanner.GetAtomIndex(aAtomName), aValue)); }
public void EndUpdate() { _currentPlanner = null; }
public void BeginUpdate(AntAIPlanner aPlanner) { _currentPlanner = aPlanner; }
/// <summary> /// Extracts condition index by condition name. /// </summary> /// <param name="aPlanner">Reference to the planner.</param> /// <param name="aAtomName">Name of the condition</param> /// <returns>Index of the condition.</returns> public int GetValue(AntAIPlanner aPlanner, string aAtomName) { return(aPlanner.GetAtomIndex(aAtomName)); }
/// <summary> /// Ends updating of the condition. /// </summary> public void EndUpdate() { _planner = null; }
/// <summary> /// Begins updating of the condition. /// Useful to use when you want change many conditions in the same time. /// </summary> /// <param name="aPlanner">Ref to the AIPlanner.</param> public void BeginUpdate(AntAIPlanner aPlanner) { _planner = aPlanner; }