from cell import Cell class Maze: def __init__(self, cells: list[list[Cell]], start: Cell, exit: Cell): self.cells = cells self.height = len(cells) self.width = len(cells[0]) if self.height > 0 else 0 self.start = start self.exit = exit def get_cell(self, x: int, y: int) -> Cell | None: if 0 <= y < self.height and 0 <= x < self.width: return self.cells[y][x] return None def get_neighbors(self, cell: Cell) -> list[Cell]: directions = [ (0, -1), (0, 1), (-1, 0), (1, 0), ] neighbors = [] for dx, dy in directions: neighbor = self.get_cell(cell.x + dx, cell.y + dy) if neighbor is not None and neighbor.is_passable(): neighbors.append(neighbor) return neighbors