2 Commits

Author SHA1 Message Date
Maoake Teriierooiterai ef030f70a7 finish to synchronize the maze generator and the solver 2026-03-26 14:19:43 +01:00
Maoake Teriierooiterai 170de8813a update the gitignore 2026-03-26 13:11:36 +01:00
5 changed files with 35 additions and 31 deletions
+1
View File
@@ -214,4 +214,5 @@ __marimo__/
# Streamlit
.streamlit/secrets.toml
test.txt
+3 -3
View File
@@ -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
+14 -4
View File
@@ -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
+2
View File
@@ -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
+13 -22
View File
@@ -1,24 +1,15 @@
B91795551793955513D3
AEC1413969686D396C52
C392BA869694552C553A
BC6AAAC1296957A917AA
83968692C292956A816A
AAC3C3843C28293AAC3A
E83816ABC3E86AAA83C2
96AAA92C3C3C56AC6C3A
A96AC2AF87AFFFA9152A
843A96EFC5057FAC2D2A
C7AA853FFFAFFFC3C142
952AA9697FAFD5145692
C3AAE83C3FAFFFC153AA
96AC16C383A9515696AA
C3C7C552AAAC3C53C16A
969555106829457A9416
856953AA946E953843C3
A93A906E85112BAE96BA
C6AAE81105684685292A
D56C546C4554554546C6
BD1553D3913
C3AD54386AA
BAC5396C7AA
82956C5396E
A86D553AC53
C295552C512
9283B9693AA
AAAAC456AAA
AC2C553D2C2
83C3D3C3E96
C454547C547
1,1
4,3
2,1
S
EENWWNNEEESESWSEESSEEESSSSWSWWNWNWWWNNWSSSESWWNWNNNENNNNNW