mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
finish to synchronize the maze generator and the solver
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
||||
WIDTH=20
|
||||
HEIGHT=20
|
||||
ENTRY=1,1
|
||||
WIDTH=11
|
||||
HEIGHT=11
|
||||
ENTRY=4,3
|
||||
EXIT=2,1
|
||||
OUTPUT_FILE=maze.txt
|
||||
PERFECT=False
|
||||
|
||||
@@ -9,7 +9,7 @@ class MazeGenerator(ABC):
|
||||
def __init__(self, start: tuple, end: tuple, perfect: bool) -> None:
|
||||
self.start = (start[0] - 1, start[1] - 1)
|
||||
self.end = (end[0] - 1, end[1] - 1)
|
||||
self.bool = bool
|
||||
self.perfect = perfect
|
||||
|
||||
@abstractmethod
|
||||
def generator(
|
||||
@@ -93,6 +93,7 @@ class MazeGenerator(ABC):
|
||||
|
||||
|
||||
class Kruskal(MazeGenerator):
|
||||
|
||||
class Set:
|
||||
def __init__(self, cells: list[int]) -> None:
|
||||
self.cells: list[int] = cells
|
||||
@@ -174,6 +175,8 @@ class Kruskal(MazeGenerator):
|
||||
cells_ft = None
|
||||
if height > 10 and width > 10:
|
||||
cells_ft = self.get_cell_ft(width, height)
|
||||
if cells_ft and (self.start in cells_ft or self.end in cells_ft):
|
||||
cells_ft = None
|
||||
|
||||
if seed is not None:
|
||||
np.random.seed(seed)
|
||||
@@ -204,13 +207,20 @@ class Kruskal(MazeGenerator):
|
||||
):
|
||||
break
|
||||
print(f"nb sets: {len(sets.sets)}")
|
||||
return self.walls_to_maze(walls, height, width)
|
||||
maze = self.walls_to_maze(walls, height, width)
|
||||
if self.perfect is False:
|
||||
gen = Kruskal.unperfect_maze(width, height, maze,
|
||||
cells_ft)
|
||||
for res in gen:
|
||||
maze = res
|
||||
yield maze
|
||||
return maze
|
||||
|
||||
|
||||
class DepthFirstSearch(MazeGenerator):
|
||||
def __init__(self, start: bool, end: bool, perfect: bool) -> None:
|
||||
self.start = start
|
||||
self.end = end
|
||||
self.start = (start[0] - 1, start[1] - 1)
|
||||
self.end = (end[0] - 1, end[1] - 1)
|
||||
self.perfect = perfect
|
||||
self.forty_two: set | None = None
|
||||
|
||||
|
||||
@@ -190,6 +190,8 @@ class DepthFirstSearchSolver(MazeSolver):
|
||||
coord = self.next_cell(coord, next)
|
||||
for m in move:
|
||||
path_str += m
|
||||
if not path:
|
||||
raise Exception("Path not found")
|
||||
return path_str
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
BD155539513D1395393B
|
||||
A96D13AA96C3AC2BAAC6
|
||||
C69146A84396C52C4693
|
||||
9380556C7AC5538553AA
|
||||
AC2C11555693BAA93C6A
|
||||
8543C29515686AAAE912
|
||||
AD3856C3C39696C41686
|
||||
C3A853969687C5396BC3
|
||||
BC2C3AAF83EFFFA83C52
|
||||
A9696AAFEC157FA8293A
|
||||
84383C6FFFAFFF86AAAA
|
||||
A96AC13D3FAFD543AAC2
|
||||
86D438452FAFFF96AA96
|
||||
C553A83B87C553A92AC3
|
||||
917A86A8411516A8447A
|
||||
AC5683AC7801696C3B96
|
||||
C393840116C414394683
|
||||
BC44696AE93D296E93AA
|
||||
A95396BC3AC3EA956802
|
||||
C4544547C454546D5446
|
||||
BD1553D3913
|
||||
C3AD54386AA
|
||||
BAC5396C7AA
|
||||
82956C5396E
|
||||
A86D553AC53
|
||||
C295552C512
|
||||
9283B9693AA
|
||||
AAAAC456AAA
|
||||
AC2C553D2C2
|
||||
83C3D3C3E96
|
||||
C454547C547
|
||||
|
||||
1,1
|
||||
4,3
|
||||
2,1
|
||||
S
|
||||
EENWWNNEEESESWSEESSEEESSSSWSWWNWNWWWNNWSSSESWWNWNNNENNNNNW
|
||||
|
||||
Reference in New Issue
Block a user