]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/PathFinder.cs
colosseum is now crowded with monsters; made the SaberMonster moving code more robust...
[chaz/carfire] / CarFire / CarFire / CarFire / PathFinder.cs
index 02c645cc8f8ed4c71e20705b96951a627acd15b4..ef41370ef4a3fc442b623d3a7d1d2be3c4748ab0 100644 (file)
@@ -68,7 +68,7 @@ namespace CarFire
         /// <param name="start">The cell to start at.</param>\r
         /// <param name="finish">The desired destination.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
         /// <param name="start">The cell to start at.</param>\r
         /// <param name="finish">The desired destination.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
-        /// ends points not included, or null if no path could be found.</return>\r
+        /// starting point not included, or null if no path could be found.</return>\r
         public List<Point> GetPath(Point start, Point finish)\r
         {\r
             return GetPath(start, finish, GetManhattanDistance, GetCost);\r
         public List<Point> GetPath(Point start, Point finish)\r
         {\r
             return GetPath(start, finish, GetManhattanDistance, GetCost);\r
@@ -82,7 +82,7 @@ namespace CarFire
         /// <param name="finish">The desired destination.</param>\r
         /// <param name="heuristic">The heuristic function.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
         /// <param name="finish">The desired destination.</param>\r
         /// <param name="heuristic">The heuristic function.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
-        /// ends points not included, or null if no path could be found.</return>\r
+        /// starting point not included, or null if no path could be found.</return>\r
         public List<Point> GetPath(Point start, Point finish, Heuristic heuristic)\r
         {\r
             return GetPath(start, finish, heuristic, GetCost);\r
         public List<Point> GetPath(Point start, Point finish, Heuristic heuristic)\r
         {\r
             return GetPath(start, finish, heuristic, GetCost);\r
@@ -96,7 +96,7 @@ namespace CarFire
         /// <param name="finish">The desired destination.</param>\r
         /// <param name="costFunction">The cost function</param>\r
         /// <returns>A list of points representing the path through the grid,\r
         /// <param name="finish">The desired destination.</param>\r
         /// <param name="costFunction">The cost function</param>\r
         /// <returns>A list of points representing the path through the grid,\r
-        /// ends points not included, or null if no path could be found.</return>\r
+        /// starting point not included, or null if no path could be found.</return>\r
         public List<Point> GetPath(Point start, Point finish, CostFunction costFunction)\r
         {\r
             return GetPath(start, finish, GetManhattanDistance, costFunction);\r
         public List<Point> GetPath(Point start, Point finish, CostFunction costFunction)\r
         {\r
             return GetPath(start, finish, GetManhattanDistance, costFunction);\r
@@ -110,7 +110,7 @@ namespace CarFire
         /// <param name="heuristic">The heuristic function.</param>\r
         /// <param name="costFunction">The cost function.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
         /// <param name="heuristic">The heuristic function.</param>\r
         /// <param name="costFunction">The cost function.</param>\r
         /// <returns>A list of points representing the path through the grid,\r
-        /// ends points not included, or null if no path could be found.</return>\r
+        /// starting point not included, or null if no path could be found.</return>\r
         public List<Point> GetPath(Point start, Point finish, Heuristic heuristic, CostFunction costFunction)\r
         {\r
             mFringe = new BinaryHeap<Cell>();\r
         public List<Point> GetPath(Point start, Point finish, Heuristic heuristic, CostFunction costFunction)\r
         {\r
             mFringe = new BinaryHeap<Cell>();\r
@@ -127,13 +127,10 @@ namespace CarFire
                 if (cell.Point == finish)\r
                 {\r
                     List<Point> list = new List<Point>();\r
                 if (cell.Point == finish)\r
                 {\r
                     List<Point> list = new List<Point>();\r
+                    list.Add(cell.Point);\r
 \r
                     cell = cell.Parent;\r
 \r
                     cell = cell.Parent;\r
-                    while (cell != null && cell.Point != start)\r
-                    {\r
-                        list.Add(cell.Point);\r
-                        cell = cell.Parent;\r
-                    }\r
+                    if (cell != null) for (; cell.Point != start; cell = cell.Parent) list.Add(cell.Point);\r
 \r
                     list.Reverse();\r
                     return list;\r
 \r
                     list.Reverse();\r
                     return list;\r
This page took 0.019297 seconds and 4 git commands to generate.