mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-29 00:14:34 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef030f70a7 | |||
| 170de8813a |
@@ -214,4 +214,5 @@ __marimo__/
|
|||||||
|
|
||||||
# Streamlit
|
# Streamlit
|
||||||
.streamlit/secrets.toml
|
.streamlit/secrets.toml
|
||||||
|
test.txt
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
WIDTH=20
|
WIDTH=11
|
||||||
HEIGHT=20
|
HEIGHT=11
|
||||||
ENTRY=1,1
|
ENTRY=4,3
|
||||||
EXIT=2,1
|
EXIT=2,1
|
||||||
OUTPUT_FILE=maze.txt
|
OUTPUT_FILE=maze.txt
|
||||||
PERFECT=False
|
PERFECT=False
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class MazeGenerator(ABC):
|
|||||||
def __init__(self, start: tuple, end: tuple, perfect: bool) -> None:
|
def __init__(self, start: tuple, end: tuple, perfect: bool) -> None:
|
||||||
self.start = (start[0] - 1, start[1] - 1)
|
self.start = (start[0] - 1, start[1] - 1)
|
||||||
self.end = (end[0] - 1, end[1] - 1)
|
self.end = (end[0] - 1, end[1] - 1)
|
||||||
self.bool = bool
|
self.perfect = perfect
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def generator(
|
def generator(
|
||||||
@@ -93,6 +93,7 @@ class MazeGenerator(ABC):
|
|||||||
|
|
||||||
|
|
||||||
class Kruskal(MazeGenerator):
|
class Kruskal(MazeGenerator):
|
||||||
|
|
||||||
class Set:
|
class Set:
|
||||||
def __init__(self, cells: list[int]) -> None:
|
def __init__(self, cells: list[int]) -> None:
|
||||||
self.cells: list[int] = cells
|
self.cells: list[int] = cells
|
||||||
@@ -174,6 +175,8 @@ class Kruskal(MazeGenerator):
|
|||||||
cells_ft = None
|
cells_ft = None
|
||||||
if height > 10 and width > 10:
|
if height > 10 and width > 10:
|
||||||
cells_ft = self.get_cell_ft(width, height)
|
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:
|
if seed is not None:
|
||||||
np.random.seed(seed)
|
np.random.seed(seed)
|
||||||
@@ -204,13 +207,20 @@ class Kruskal(MazeGenerator):
|
|||||||
):
|
):
|
||||||
break
|
break
|
||||||
print(f"nb sets: {len(sets.sets)}")
|
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):
|
class DepthFirstSearch(MazeGenerator):
|
||||||
def __init__(self, start: bool, end: bool, perfect: bool) -> None:
|
def __init__(self, start: bool, end: bool, perfect: bool) -> None:
|
||||||
self.start = start
|
self.start = (start[0] - 1, start[1] - 1)
|
||||||
self.end = end
|
self.end = (end[0] - 1, end[1] - 1)
|
||||||
self.perfect = perfect
|
self.perfect = perfect
|
||||||
self.forty_two: set | None = None
|
self.forty_two: set | None = None
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,8 @@ class DepthFirstSearchSolver(MazeSolver):
|
|||||||
coord = self.next_cell(coord, next)
|
coord = self.next_cell(coord, next)
|
||||||
for m in move:
|
for m in move:
|
||||||
path_str += m
|
path_str += m
|
||||||
|
if not path:
|
||||||
|
raise Exception("Path not found")
|
||||||
return path_str
|
return path_str
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,24 +1,15 @@
|
|||||||
B91795551793955513D3
|
BD1553D3913
|
||||||
AEC1413969686D396C52
|
C3AD54386AA
|
||||||
C392BA869694552C553A
|
BAC5396C7AA
|
||||||
BC6AAAC1296957A917AA
|
82956C5396E
|
||||||
83968692C292956A816A
|
A86D553AC53
|
||||||
AAC3C3843C28293AAC3A
|
C295552C512
|
||||||
E83816ABC3E86AAA83C2
|
9283B9693AA
|
||||||
96AAA92C3C3C56AC6C3A
|
AAAAC456AAA
|
||||||
A96AC2AF87AFFFA9152A
|
AC2C553D2C2
|
||||||
843A96EFC5057FAC2D2A
|
83C3D3C3E96
|
||||||
C7AA853FFFAFFFC3C142
|
C454547C547
|
||||||
952AA9697FAFD5145692
|
|
||||||
C3AAE83C3FAFFFC153AA
|
|
||||||
96AC16C383A9515696AA
|
|
||||||
C3C7C552AAAC3C53C16A
|
|
||||||
969555106829457A9416
|
|
||||||
856953AA946E953843C3
|
|
||||||
A93A906E85112BAE96BA
|
|
||||||
C6AAE81105684685292A
|
|
||||||
D56C546C4554554546C6
|
|
||||||
|
|
||||||
1,1
|
4,3
|
||||||
2,1
|
2,1
|
||||||
S
|
EENWWNNEEESESWSEESSEEESSSSWSWWNWNWWWNNWSSSESWWNWNNNENNNNNW
|
||||||
|
|||||||
Reference in New Issue
Block a user