forked from UNN/2026-rff_mp
32 lines
726 B
Python
32 lines
726 B
Python
#!/usr/bin/env python
|
|
# coding: utf-8
|
|
|
|
# In[ ]:
|
|
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
@dataclass
|
|
class Cell:
|
|
"""Клетка лабиринта."""
|
|
x: int
|
|
y: int
|
|
is_wall: bool = False
|
|
is_start: bool = False
|
|
is_exit: bool = False
|
|
weight: int = 1 # Для взвешенных лабиринтов (доп. задание)
|
|
|
|
def is_passable(self) -> bool:
|
|
"""Проходима ли клетка."""
|
|
return not self.is_wall
|
|
|
|
def __hash__(self) -> int:
|
|
return hash((self.x, self.y))
|
|
|
|
def __eq__(self, other) -> bool:
|
|
if not isinstance(other, Cell):
|
|
return False
|
|
return self.x == other.x and self.y == other.y
|
|
|