[2] добавил тестовые лабиринты

This commit is contained in:
raskatovia 2026-05-23 12:11:53 +03:00
parent fa3d95b5c0
commit c19eb1a1f6
3 changed files with 32 additions and 9 deletions

View File

@ -0,0 +1,9 @@
###############
#S....#.......#
#.###.#.#####.#
#...#.#.....#.#
###.#.#####.#.#
#...#.....#.#.#
#.#######.#.#.#
#............F#
###############

View File

@ -0,0 +1,7 @@
###########
#S..#.....#
###.#.###.#
#...#...#.#
#.#####.#.#
#.......#F#
###########

View File

@ -115,14 +115,21 @@ class MazeSolver:
return self.strategy.solve(maze) return self.strategy.solve(maze)
if __name__ == "__main__": if __name__ == "__main__":
maze = MazeBuilder().from_file("raskatovia/docs/data/task2/maps/simple.txt").build() files = [
"simple.txt",
"medium.txt",
"hard.txt"
]
strategies = [BfsStrategy(), DfsStrategy(), AstarStrategy()] strategies = [BfsStrategy(), DfsStrategy(), AstarStrategy()]
for strategy in strategies: for filename in files:
solver = MazeSolver(strategy) print("map:", filename)
result = solver.solve(maze) maze = MazeBuilder().from_file("raskatovia/docs/data/task2/maps/" + filename).build()
print("algorithm:", result["name"]) for strategy in strategies:
print("visited:", result["visited"]) solver = MazeSolver(strategy)
print("length:", result["length"]) result = solver.solve(maze)
print(maze.draw(result["path"])) print("algorithm:", result["name"])
print() print("visited:", result["visited"])
print("length:", result["length"])
print(maze.draw(result["path"]))
print()