2026-rff_mp/pomelovsd/ExitMaze/Core/Benchmark.py

20 lines
567 B
Python
Raw Normal View History

2026-05-22 21:45:19 +00:00
from MazeSolver.Solver import MazeSolver
import csv
2026-05-22 22:06:48 +00:00
def RunBenchmark(maze, strategies, repeats = 5):
2026-05-22 21:45:19 +00:00
rows = []
2026-05-22 22:06:48 +00:00
for name, strategy in strategies.items():
2026-05-22 21:45:19 +00:00
2026-05-22 22:06:48 +00:00
solver = MazeSolver(maze, strategy)
for _ in range(repeats):
stats, _ = solver.solve()
rows.append([name, stats.time_ms, stats.visited_cells, stats.path_length])
with open("results.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["strategy", "time_ms", "visited", "path_length"])
2026-05-23 10:37:43 +00:00
writer.writerows(rows)