mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
add ft logo to maze
This commit is contained in:
@@ -100,9 +100,25 @@ class Kruskal(MazeGenerator):
|
|||||||
return
|
return
|
||||||
raise Exception("two sets not found")
|
raise Exception("two sets not found")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def touch_ft(
|
||||||
|
width: int,
|
||||||
|
wall: tuple[int, int],
|
||||||
|
cells_ft: None | set[tuple[int, int]],
|
||||||
|
) -> bool:
|
||||||
|
if cells_ft is None:
|
||||||
|
return False
|
||||||
|
s1 = (wall[0] / width, wall[0] % width)
|
||||||
|
s2 = (wall[1] / width, wall[1] % width)
|
||||||
|
return s1 in cells_ft or s2 in cells_ft
|
||||||
|
|
||||||
def generator(
|
def generator(
|
||||||
self, height: int, width: int, seed: int = None
|
self, height: int, width: int, seed: int = None
|
||||||
) -> Generator[np.ndarray, None, np.ndarray]:
|
) -> Generator[np.ndarray, None, np.ndarray]:
|
||||||
|
cells_ft = None
|
||||||
|
if height > 10 and width > 10:
|
||||||
|
cells_ft = self.get_cell_ft(width, height)
|
||||||
|
|
||||||
if seed is not None:
|
if seed is not None:
|
||||||
np.random.seed(seed)
|
np.random.seed(seed)
|
||||||
sets = self.Sets([self.Set([i]) for i in range(height * width)])
|
sets = self.Sets([self.Set([i]) for i in range(height * width)])
|
||||||
@@ -117,13 +133,15 @@ class Kruskal(MazeGenerator):
|
|||||||
np.random.shuffle(walls)
|
np.random.shuffle(walls)
|
||||||
|
|
||||||
yield self.walls_to_maze(walls, height, width)
|
yield self.walls_to_maze(walls, height, width)
|
||||||
while len(sets.sets) > 1:
|
while len(sets.sets) != 1 and (len(sets.sets) != 19 and cells_ft not None):
|
||||||
for wall in walls:
|
for wall in walls:
|
||||||
if not self.is_in_same_set(sets, wall):
|
if not self.is_in_same_set(sets, wall) and not self.touch_ft(
|
||||||
|
width, wall, cells_ft
|
||||||
|
):
|
||||||
self.merge_sets(sets, wall)
|
self.merge_sets(sets, wall)
|
||||||
walls.remove(wall)
|
walls.remove(wall)
|
||||||
yield self.walls_to_maze(walls, height, width)
|
yield self.walls_to_maze(walls, height, width)
|
||||||
if len(sets.sets) == 1:
|
if len(sets.sets) == 19:
|
||||||
break
|
break
|
||||||
print(f"nb sets: {len(sets.sets)}")
|
print(f"nb sets: {len(sets.sets)}")
|
||||||
return self.walls_to_maze(walls, height, width)
|
return self.walls_to_maze(walls, height, width)
|
||||||
@@ -239,8 +257,9 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lock_cell_ft(visited: np.ndarray, forty_two: set[tuple[int]]
|
def lock_cell_ft(
|
||||||
) -> np.ndarray:
|
visited: np.ndarray, forty_two: set[tuple[int]]
|
||||||
|
) -> np.ndarray:
|
||||||
tab = [cell for cell in forty_two]
|
tab = [cell for cell in forty_two]
|
||||||
for cell in tab:
|
for cell in tab:
|
||||||
visited[cell] = True
|
visited[cell] = True
|
||||||
|
|||||||
Reference in New Issue
Block a user