fix Astar solver

This commit is contained in:
2026-04-03 17:59:37 +02:00
parent 6189d7f321
commit 04c28a851f
3 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -84,7 +84,8 @@ class AStar(MazeSolver):
start: Start coordinates using 1-based indexing.
end: End coordinates using 1-based indexing.
"""
super().__init__(start, end)
self.start = (start[0] - 1, start[1] - 1)
self.end = (end[0] - 1, end[1] - 1)
def h(self, n: tuple[int, int]) -> int:
"""Compute the Manhattan distance heuristic to the goal.
@@ -196,6 +197,8 @@ class AStar(MazeSolver):
to_check,
)
)
if path == self.end:
break
raise Exception("Path not found")
def get_rev_dir(self, current: Node) -> str: