diff --git a/SmirnovaVYu/docs/data/models.py b/SmirnovaVYu/docs/data/models.py deleted file mode 100644 index 5932d5f..0000000 --- a/SmirnovaVYu/docs/data/models.py +++ /dev/null @@ -1,79 +0,0 @@ -from typing import List, Optional - - -class Cell: - - def __init__(self, x: int, y: int): - self.x = x - self.y = y - self.is_wall = False - self.is_start = False - self.is_exit = False - - def is_passable(self) -> bool: - return not self.is_wall - - def __eq__(self, other) -> bool: - if not isinstance(other, Cell): - return False - return self.x == other.x and self.y == other.y - - def __hash__(self): - return hash((self.x, self.y)) - - def __repr__(self): - return f"Cell({self.x}, {self.y})" - - -class Maze: - - def __init__(self, width: int, height: int): - self.width = width - self.height = height - self._cells: List[List[Optional[Cell]]] = [[None for _ in range(width)] for _ in range(height)] - self.start: Optional[Cell] = None - self.exit: Optional[Cell] = None - - def set_cell(self, x: int, y: int, cell: Cell) -> None: - if 0 <= x < self.width and 0 <= y < self.height: - self._cells[y][x] = cell - if cell.is_start: - self.start = cell - if cell.is_exit: - self.exit = cell - - def get_cell(self, x: int, y: int) -> Optional[Cell]: - if 0 <= x < self.width and 0 <= y < self.height: - return self._cells[y][x] - return None - - def get_neighbors(self, cell: Cell) -> List[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 __str__(self) -> str: - result = [] - for y in range(self.height): - row = [] - for x in range(self.width): - cell = self.get_cell(x, y) - if cell is None: - row.append('?') - elif cell.is_start: - row.append('S') - elif cell.is_exit: - row.append('E') - elif cell.is_wall: - row.append('#') - else: - row.append(' ') - result.append(''.join(row)) - return '\n'.join(result) \ No newline at end of file