From 8656736ea4dcaee031c2dc15f41453aefe28b882 Mon Sep 17 00:00:00 2001 From: Jan Mrna Date: Sat, 20 Sep 2025 17:19:10 +0200 Subject: [PATCH] Increase map size, add labels --- README.md | 1 + python/pathfinding_demo.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 71770c3..3264b4b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ - [x] GBFS - [x] A* - [x] performance measurement: time/visited nodes + - [ ] finalize the script and copy back to the jupyter notebook - [ ] finish text on the page - [x] create a dedicated python script - [ ] C++ diff --git a/python/pathfinding_demo.py b/python/pathfinding_demo.py index 4998d30..af55823 100644 --- a/python/pathfinding_demo.py +++ b/python/pathfinding_demo.py @@ -117,6 +117,7 @@ class Visualizer: self._axes.plot(xs, ys, 'o-', color=color, label=label) self._axes.plot(xs[0], ys[0], 'o', color='lime', markersize=8) # starting point self._axes.plot(xs[-1], ys[-1], 'o', color='magenta', markersize=8) # end point + self._axes.legend() # @@ -395,10 +396,10 @@ class A_star(PathFinderBase): def main(): # Define the map and start/stop points - m = Map(15,10) + m = Map(30,20) m.Randomize() - starting_point: Point2D = Point2D((1,1)) - end_point: Point2D = Point2D((5,5)) + starting_point: Point2D = Point2D((29,19)) + end_point: Point2D = Point2D((1,1)) path_finder_classes: list[type[PathFinderBase]] = [ DFS, @@ -419,7 +420,7 @@ def main(): if path is not None: cost = m.GetPathCost(path) print(f"{path_finder.name:24}: took {elapsed_time/1e6:.3f} ms, visited {visited_nodes} nodes, cost {cost:.2f}") - v.DrawPath(path) + v.DrawPath(path, label=path_finder.name) else: print(f"{path_finder.name}: No path found")