from typing import List, Optional class Maze: #лабиринт def __init__(self, width: int, height: int): self.width = width self.height = height self.cells = [[None for _ in range(width)] for _ in range(height)] self.start = None self.exit = None def set_cell(self, x: int, y: int, cell): #устанавливает клетки в лаб if 0 <= x < self.width and 0 <= y < self.height: self.cells[y][x] = cell def get_cell(self, x: int, y: int): if 0 <= x < self.width and 0 <= y < self.height: return self.cells[y][x] return None def get_neighbors(self, cell): neighbors = [] # вверх, вниз, влево, вправо directions = [(0, -1), (0, 1), (-1, 0), (1, 0)] for dx, dy in directions: nx, ny = cell.x + dx, cell.y + dy neighbor = self.get_cell(nx, ny) if neighbor and neighbor.is_passable(): neighbors.append(neighbor) return neighbors def __repr__(self): return f"Maze({self.width}x{self.height}, start={self.start}, exit={self.exit})"