Ejemplo n.º 1
0
            // methods
            #region private static Stepper<T> BuildPath(Node node)
            /// <summary>Builds the path from resulting from the A* algorithm.</summary>
            /// <param name="node">The resulting final node fromt he A* algorithm.</param>
            /// <returns>A stepper function of the computed path frmo the A* algorithm.</returns>
            private static Stepper <T> Astar_BuildPath(Astar_Node node)
            {
                Astar_PathNode end;
                Astar_PathNode start = Astar_BuildPath(node, out end);

                return((Step <T> step) =>
                {
                    Astar_PathNode current = start;
                    while (current != null)
                    {
                        step(current.Value);
                        current = current.Next;
                    }
                });
            }
Ejemplo n.º 2
0
 private static Astar_PathNode Astar_BuildPath(Astar_Node currentNode, out Astar_PathNode currentPathNode)
 {
     if (currentNode.Previous == null)
     {
         Astar_PathNode start = new Astar_PathNode(currentNode.Value);
         currentPathNode = start;
         return(start);
     }
     else
     {
         Astar_PathNode previous;
         Astar_PathNode start = Astar_BuildPath(currentNode.Previous, out previous);
         currentPathNode = new Astar_PathNode(currentNode.Value);
         previous.Next   = currentPathNode;
         return(start);
     }
 }