示例#1
0
        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>();
        }
示例#2
0
文件: Brew.cs 项目: BNHeadrick/Bros
 /**
  * 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);
 }
示例#3
0
 /**
  * Determiens if two objects are the same
  *@param other the other object
  */
 public override bool equals(PuzzleObject other)
 {
     return (other.type == type);
 }
示例#4
0
 public bool isSameAs(PuzzleObject other)
 {
     return (id == other.id);
 }
示例#5
0
 /**
  * Determiens if two objects are the same
  *@param other the other object
  */
 public abstract bool equals(PuzzleObject other);
示例#6
0
 /**
  * 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;
 }
示例#7
0
 /**
  * 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;
 }
示例#8
0
 public void addTaskToPlan(PuzzleObject po)
 {
     if (currPlan == null)
     {
         currPlan = new ActionNode(po);
     }
     else
     {
         currPlan.addLeaf(new ActionNode(po));
     }
     currPlan.debugPrint();
 }