add generator to my maze generator DFS

This commit is contained in:
Maoake Teriierooiterai
2026-03-24 15:22:20 +01:00
parent a85e342a0a
commit 993bcce857
2 changed files with 9 additions and 17 deletions
+4 -3
View File
@@ -84,10 +84,10 @@ class Kruskal(MazeGenerator):
return self.walls_to_maze(walls, height, width)
class DepthFirstSearch:
class DepthFirstSearch(MazeGenerator):
@staticmethod
def generator(width: int, height: int) -> np.ndarray:
def generator(self, width: int, height: int
) -> Generator[np.ndarray, None, np.ndarray]:
maze = DepthFirstSearch.init_maze(width, height)
visited = np.zeros((height, width), dtype=bool)
path = list()
@@ -117,6 +117,7 @@ class DepthFirstSearch:
wall_r = DepthFirstSearch.reverse_path(wall)
x, y = coord
maze[y][x] = DepthFirstSearch.broken_wall(maze[y][x], wall_r)
yield maze
return maze
@staticmethod