From 1818154b9a39607e8e70d7ace4b5d6c96df8b9df Mon Sep 17 00:00:00 2001 From: smirnovavyu Date: Fri, 4 Sep 2026 15:15:38 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20Sm?= =?UTF-8?q?irnovaVYu/docs/data/solver.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SmirnovaVYu/docs/data/solver.py | 49 --------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 SmirnovaVYu/docs/data/solver.py diff --git a/SmirnovaVYu/docs/data/solver.py b/SmirnovaVYu/docs/data/solver.py deleted file mode 100644 index 137e481d..00000000 --- a/SmirnovaVYu/docs/data/solver.py +++ /dev/null @@ -1,49 +0,0 @@ -import time -from dataclasses import dataclass -from typing import List, Optional, Tuple -from models import Cell, Maze -from strategies import PathFindingStrategy - - -@dataclass -class SearchStats: - time_ms: float - visited_cells: int - path_length: int - path_found: bool = True - - def __str__(self) -> str: - if not self.path_found: - return f"Путь не найден (время: {self.time_ms:.2f} мс)" - return (f"Время: {self.time_ms:.2f} мс, " - f"Посещено клеток: {self.visited_cells}, " - f"Длина пути: {self.path_length}") - - -class MazeSolver: - - def __init__(self, maze: Maze, strategy: Optional[PathFindingStrategy] = None): - self.maze = maze - self._strategy = strategy - - def set_strategy(self, strategy: PathFindingStrategy) -> None: - self._strategy = strategy - - def solve(self) -> Tuple[List[Cell], SearchStats]: - if self._strategy is None: - raise ValueError("Стратегия не установлена") - - 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 - - stats = SearchStats( - time_ms=time_ms, - visited_cells=len(path) if path else 0, - path_length=len(path) if path else 0, - path_found=bool(path) - ) - - return path, stats \ No newline at end of file