// Base Constructor public Node(Node parent, float cost, List <State> allStates, GAction action) { this.parent = parent; this.cost = cost; this.state = new List <State>(allStates); this.action = action; }
/// <summary> /// Load next action in the queue. /// </summary> private void LoadNextAction() { // ------- HAS AN ACTION QUEUE CONTAINING ACTIONS ------- if (actionQueue != null && actionQueue.Count > 0) { // --------- SET CURRENT ACTION TO NEXT ACTION ---------- currentAction = actionQueue.Dequeue(); // ----------- CHECKS PRE PERFORM CONDITIONS ------------ if (currentAction.PrePerform(this)) { Debug.Log($"Pre perform successful for {currentAction.name}."); // ------------------ ACTIVATE ACTION ------------------- isRunningAction = true; currentAction.RunMainAction(this); } else { // ----------------- FORCE A NEW PLAN ----------------- actionQueue = null; } } }
/// <summary> /// Returns a new list that doesn't contain the removed action. /// </summary> private List <GAction> ActionSubset(List <GAction> actions, GAction removeMe) { List <GAction> subset = new List <GAction>(); foreach (GAction a in actions) { if (!a.Equals(removeMe)) { subset.Add(a); } } return(subset); }
// Overloaded Constructor public Node(Node parent, float cost, List <State> allStates, List <State> beliefStates, GAction action) { this.parent = parent; this.cost = cost; this.state = new List <State>(allStates); this.action = action; // Merge beliefs into all states dictionary foreach (var b in beliefStates) { if (!this.state.Contains(b)) { this.state.Add(b); } } }