opti path

This commit is contained in:
Maoake Teriierooiterai
2026-03-29 14:31:04 +02:00
parent d534993f4c
commit b682274102
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -3,6 +3,6 @@ HEIGHT=11
ENTRY=1,1
EXIT=11,11
OUTPUT_FILE=maze.txt
PERFECT=True
PERFECT=False
GENERATOR=Kruskal
SOLVER=AStar
SOLVER=DFS
+7
View File
@@ -166,6 +166,13 @@ class DepthFirstSearchSolver(MazeSolver):
def solve(self, maze: Maze, height: int = None,
width: int = None) -> str:
res = list()
for _ in range(60):
res.append(self.get_path(maze, height, width))
return min(res, key=lambda x: len(x))
def get_path(self, maze: Maze, height: int = None,
width: int = None) -> str:
path_str = ""
visited = np.zeros((height, width), dtype=bool)
path = list()