private List<ActionNode> parents; /**< the previous nodes */ #endregion Fields #region Constructors /** * Creates a new node *@param _data the data */ public ActionNode(PuzzleObject _data) { value = 0; data = _data.copy(); id = next_id; next_id++; children = new List<ActionNode>(); parents = new List<ActionNode>(); }
/** * Determiens if two objects are the same *@param other the other object */ public override bool equals(PuzzleObject other) { return (other.type == type && ((Brew)other).color == color && ((Brew)other).uncolor == uncolor); }
/** * Determiens if two objects are the same *@param other the other object */ public override bool equals(PuzzleObject other) { return (other.type == type); }
public bool isSameAs(PuzzleObject other) { return (id == other.id); }
/** * Determiens if two objects are the same *@param other the other object */ public abstract bool equals(PuzzleObject other);
/** * Finds a node and returns the depth of it *@param findData the node to find *@return the depth or -1 if not present */ public int findNodeDepth(PuzzleObject findData, List<int> visited) { List<ActionNode> next = new List<ActionNode>(); //next.Add(this); for (int j = children.Count - 1; j >= 0; j--) { next.Add(children[j]); } for (int i = 0; i < next.Count; i++) { if (!visited.Contains(next[i].id) && findData.equals(next[i].data)) { return i; } for (int j = next[i].children.Count - 1; j >= 0; j--) { next.Add(next[i].children[j]); } } return -1; }
/** * Finds a node and returns the depth of it *@param findData the node to find *@return the depth or -1 if not present */ public int findNodeDepth(PuzzleObject findData) { List<ActionNode> next = new List<ActionNode>(); //next.Add(this); for (int j = children.Count-1; j >= 0; j--) { next.Add(children[j]); } for (int i = 0; i < next.Count; i++) { if (findData.equals(next[i].data)) { if (i - next[i].parents.Count-next[i].value < 0) { return (i - next[i].parents.Count - next[i].value - 1); } return (i - next[i].parents.Count - next[i].value); } for (int j = next[i].children.Count-1; j >= 0; j--) { next.Add(next[i].children[j]); } } return -1; }
public void addTaskToPlan(PuzzleObject po) { if (currPlan == null) { currPlan = new ActionNode(po); } else { currPlan.addLeaf(new ActionNode(po)); } currPlan.debugPrint(); }