Example #1
0
 ///<summary>Creates a path from the ending node to its first parent</summary>
 /// <param name="endingNode">Ending node to trace a path using its parents</param>
 ///<returns>Returns a path from the starting node to the ending node</returns>
 private Path retracePath(Node endingNode)
 {
     Path path = new Path();
     path.AppendNode(endingNode);
     while (endingNode.Parent != null)
     {
         endingNode = endingNode.Parent;
         path.AppendNode(endingNode);
     }
     path.ReversePath();
     return path;
 }
Example #2
0
        ///<summary>Generates an ASCII map with the path designated as stars and nodes not on the path as 0's</summary>
        ///<param name="path">Path to display in stars</param>         
        ///<returns>Returns a sting containing an ASCII map with the path as stars</returns>
        public string GetASCIIMap(Path path)
        {
            string[,] ASCIIMap = new string[_xNodes,_yNodes];
            for (int i = 0; i < _xNodes; i++)
            {
                for (int j = 0; j < _xNodes; j++)
                {
                    ASCIIMap[i, j] = "0";
                }
            }
            foreach (Node node in path.GetPath())
            {
                ASCIIMap[node.Postition.X, node.Postition.Y] = "*";
            }
            string ASCIIMapString = "";
            for (int i = 0; i < _xNodes; i++)
            {
                for (int j = 0; j < _xNodes; j++)
                {
                    ASCIIMapString += ASCIIMap[i, j];
                    if (j == _yNodes - 1)
                    {
                        ASCIIMapString += "\n";
                    }
                }
            }

            return ASCIIMapString;
        }