[2] maze #332

Merged
git_admin merged 9 commits from lomakinae/2026-rff_mp:maze into develop 2026-05-30 11:16:27 +00:00
Showing only changes of commit e6e4ae9a99 - Show all commits

View File

@ -0,0 +1,35 @@
import time
from typing import NamedTuple
from .maze import Maze
from .strategies import PathFindingStrategy
class SearchStats(NamedTuple):
time_ms: float
visited_cells: int
path_length: int
class MazeSolver:
def __init__(self, maze: Maze):
self.maze = maze
self.strategy = None
def set_strategy(self, strategy: PathFindingStrategy):
self.strategy = strategy
def solve(self) -> SearchStats:
if self.strategy is None:
raise ValueError("Strategy not set")
start_time = time.perf_counter()
path = self.strategy.find_path(self.maze, self.maze.start, self.maze.exit)
end_time = time.perf_counter()
time_ms = (end_time - start_time) * 1000
return SearchStats(
time_ms=time_ms,
visited_cells=self.strategy.visited_count,
path_length=len(path),
)