mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
Merge branch 'main' of github.com:maoakeEnterprise/amazing into mlx
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class AMazeIng(BaseModel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def solve_path(self) -> str:
|
def solve_path(self) -> str:
|
||||||
return self.solver.solve(self.maze)
|
return self.solver.solve(self.maze, self.height, self.width)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
res = self.maze.__str__()
|
res = self.maze.__str__()
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ class AStar(MazeSolver):
|
|||||||
str(list(c[1].keys())[0]) for c in path if len(c[1]) > 0
|
str(list(c[1].keys())[0]) for c in path if len(c[1]) > 0
|
||||||
)
|
)
|
||||||
|
|
||||||
def solve(self, maze: Maze) -> str:
|
def solve(self, maze: Maze, height: int = None,
|
||||||
|
width: int = None) -> str:
|
||||||
res = self.get_path(maze.get_maze())
|
res = self.get_path(maze.get_maze())
|
||||||
if res is None:
|
if res is None:
|
||||||
raise Exception("Path not found")
|
raise Exception("Path not found")
|
||||||
@@ -161,8 +162,7 @@ class AStar(MazeSolver):
|
|||||||
|
|
||||||
class DepthFirstSearchSolver(MazeSolver):
|
class DepthFirstSearchSolver(MazeSolver):
|
||||||
def __init__(self, start, end):
|
def __init__(self, start, end):
|
||||||
self.start = (start[1] - 1, start[0] - 1)
|
super().__init__(start, end)
|
||||||
self.end = (end[1] - 1, end[0] - 1)
|
|
||||||
|
|
||||||
def solve(self, maze: Maze, height: int = None,
|
def solve(self, maze: Maze, height: int = None,
|
||||||
width: int = None) -> str:
|
width: int = None) -> str:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from src.amaz_lib.MazeGenerator import DepthFirstSearch, Kruskal
|
from src.amaz_lib.MazeGenerator import DepthFirstSearch, Kruskal
|
||||||
from src.amaz_lib.MazeSolver import AStar
|
from src.amaz_lib.MazeSolver import AStar, DepthFirstSearchSolver
|
||||||
|
|
||||||
|
|
||||||
class DataMaze:
|
class DataMaze:
|
||||||
@@ -68,6 +68,7 @@ class DataMaze:
|
|||||||
}
|
}
|
||||||
available_solver = {
|
available_solver = {
|
||||||
"AStar": AStar,
|
"AStar": AStar,
|
||||||
|
"DFS": DepthFirstSearchSolver
|
||||||
}
|
}
|
||||||
res = {}
|
res = {}
|
||||||
res["GENERATOR"] = available_generator[data["GENERATOR"]](entry, exit,
|
res["GENERATOR"] = available_generator[data["GENERATOR"]](entry, exit,
|
||||||
|
|||||||
Reference in New Issue
Block a user