Beispiel #1
0
        public gxtPathPlanNode AddToOpenSet(gxtPathNode node, gxtPathPlanNode prevNode)
        {
            //int index = nodes.Keys.GetEnumerator().
            gxtPathNode searchNode = node;
            gxtPathPlanNode thisNode = null;

            if (nodes.ContainsKey(node))
            {
                thisNode = new gxtPathPlanNode(node, prevNode, goal);
                nodes.Add(node, thisNode);
            }
            else
            {
                thisNode = nodes[searchNode];
                thisNode.IsClosed = false;
            }

            InsertNode(thisNode);

            return thisNode;
        }
Beispiel #2
0
 public void AddToClosedSet(gxtPathPlanNode node)
 {
     node.IsClosed = true;
 }
Beispiel #3
0
        public gxtPathPlan RebuildPath(gxtPathPlanNode pathGoalNode)
        {
            gxtPathPlan plan = new gxtPathPlan();

            gxtPathPlanNode tmpGoal = pathGoalNode;

            while (tmpGoal != null)
            {
                plan.AddNode(tmpGoal.Node);
                tmpGoal = tmpGoal.Prev;
            }

            return plan;
        }
Beispiel #4
0
 public void ReinsertNode(gxtPathPlanNode planNode)
 {
     for (int i = 0; i < openSet.Count; i++)
     {
         if (openSet[i] == planNode)
         {
             openSet.RemoveAt(i);
             InsertNode(planNode);
             return;
         }
     }
     InsertNode(planNode);
 }
Beispiel #5
0
        public void InsertNode(gxtPathPlanNode planNode)
        {
            // just add the node if the open set is empty
            if (openSet.Count == 0)
            {
                openSet.Add(planNode);
                return;
            }

            // otherwise, perform an insertion sort
            int index = 0;
            gxtPathPlanNode compareNode = openSet[index];
            while (compareNode < planNode)
            {
                ++index;
                if (index != openSet.Count)
                    compareNode = openSet[index];
                else
                    break;
            }
            openSet.Insert(index, planNode);
        }