mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
fix Astar solver
This commit is contained in:
+3
-3
@@ -1,7 +1,7 @@
|
||||
WIDTH=100
|
||||
HEIGHT=100
|
||||
WIDTH=15
|
||||
HEIGHT=15
|
||||
ENTRY=1,1
|
||||
EXIT=5,7
|
||||
EXIT=15,10
|
||||
OUTPUT_FILE=con
|
||||
PERFECT=True
|
||||
GENERATOR=Kruskal
|
||||
|
||||
Binary file not shown.
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user