mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
opti path
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user