27 lines
590 B
Python
27 lines
590 B
Python
|
|
from dataclasses import dataclass
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class Cell:
|
||
|
|
x: int
|
||
|
|
y: int
|
||
|
|
isWall: bool = False
|
||
|
|
isStart: bool = False
|
||
|
|
isExit: bool = False
|
||
|
|
weight: int = 1
|
||
|
|
|
||
|
|
def isPassable(self):
|
||
|
|
return not self.isWall
|
||
|
|
|
||
|
|
def __repr__(self):
|
||
|
|
parts = [f"Cell({self.x}, {self.y}"]
|
||
|
|
if self.isWall:
|
||
|
|
parts.append("WALL")
|
||
|
|
if self.isStart:
|
||
|
|
parts.append("START")
|
||
|
|
if self.isExit:
|
||
|
|
parts.append("EXIT")
|
||
|
|
if self.weight != 1:
|
||
|
|
parts.append(f"w={self.weight}")
|
||
|
|
return ", ".join(parts) + ")"
|