fix 42 logo adapt with size

This commit is contained in:
2026-03-25 15:50:08 +01:00
parent 3fa0d3204e
commit e717bf52e9
2 changed files with 11 additions and 6 deletions
+3 -2
View File
@@ -7,10 +7,11 @@ import src.amaz_lib as g
def main(maze_gen: MazeGenerator) -> None: def main(maze_gen: MazeGenerator) -> None:
# try: # try:
maze = Maze(maze=None) maze = Maze(maze=None)
for alg in maze_gen.generator(10, 10): for alg in maze_gen.generator(21, 21):
maze.set_maze(alg) maze.set_maze(alg)
os.system("clear") os.system("clear")
maze.ascii_print() maze.ascii_print()
maze.ascii_print()
# solver = AStar((1, 1), (14, 18)) # solver = AStar((1, 1), (14, 18))
# print(solver.solve(maze)) # print(solver.solve(maze))
@@ -20,4 +21,4 @@ def main(maze_gen: MazeGenerator) -> None:
if __name__ == "__main__": if __name__ == "__main__":
main(g.DepthFirstSearch()) main(g.Kruskal())
+8 -4
View File
@@ -108,8 +108,8 @@ class Kruskal(MazeGenerator):
) -> bool: ) -> bool:
if cells_ft is None: if cells_ft is None:
return False return False
s1 = (wall[0] / width, wall[0] % width) s1 = (math.trunc(wall[0] / width), wall[0] % width)
s2 = (wall[1] / width, wall[1] % width) s2 = (math.trunc(wall[1] / width), wall[1] % width)
return s1 in cells_ft or s2 in cells_ft return s1 in cells_ft or s2 in cells_ft
def generator( def generator(
@@ -133,7 +133,9 @@ 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 and (len(sets.sets) != 19 and cells_ft not None): while (len(sets.sets) != 1 and cells_ft is None) or (
len(sets.sets) != 19 and cells_ft is not None
):
for wall in walls: for wall in walls:
if not self.is_in_same_set(sets, wall) and not self.touch_ft( if not self.is_in_same_set(sets, wall) and not self.touch_ft(
width, wall, cells_ft width, wall, cells_ft
@@ -141,7 +143,9 @@ class Kruskal(MazeGenerator):
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) == 19: if (len(sets.sets) == 1 and cells_ft is None) or (
len(sets.sets) == 19 and cells_ft is not None
):
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)