forked from UNN/2026-rff_mp
32 lines
784 B
Python
32 lines
784 B
Python
from src.solver.search_stats import SearchStats
|
|
|
|
class MazeSolver:
|
|
def __init__(self, maze, strategy):
|
|
self.maze = maze
|
|
self.strategy = strategy
|
|
|
|
def solve(self):
|
|
import time
|
|
t0 = time.perf_counter()
|
|
|
|
if self.maze.exit is None:
|
|
t1 = time.perf_counter()
|
|
return SearchStats(
|
|
time_ms=(t1 - t0) * 1000,
|
|
visited=0,
|
|
path_len=0
|
|
)
|
|
|
|
path, visited = self.strategy.find_path(
|
|
self.maze,
|
|
self.maze.start,
|
|
self.maze.exit
|
|
)
|
|
|
|
t1 = time.perf_counter()
|
|
|
|
return SearchStats(
|
|
time_ms=(t1 - t0) * 1000,
|
|
visited=len(visited),
|
|
path_len=len(path) if path else 0
|
|
) |