From 588c92ff9252769a22ff46b25e60566ab67cc003 Mon Sep 17 00:00:00 2001 From: Stegallo Date: Sun, 8 Dec 2024 15:34:58 -0800 Subject: [PATCH] add left --- common/grid.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/grid.py b/common/grid.py index 27d6532..a527b2d 100644 --- a/common/grid.py +++ b/common/grid.py @@ -25,16 +25,27 @@ def __hash__(self) -> int: return hash((self.x, self.y)) def right(self): - if (self.y, self.x) == (-1, 0): + if self.icon == "^": return Direction(0, 1, ">") - if (self.y, self.x) == (0, 1): + if self.icon == ">": return Direction(1, 0, "v") - if (self.y, self.x) == (1, 0): + if self.icon == "v": return Direction(0, -1, "<") - if (self.y, self.x) == (0, -1): + if self.icon == "<": return Direction(-1, 0, "^") raise Exception + def left(self): + if self.icon == "^": + return Direction(0, -1, "<") + if self.icon == ">": + return Direction(-1, 0, "^") + if self.icon == "v": + return Direction(0, 1, ">") + if self.icon == "<": + return Direction(1, 0, "v") + raise Exception + @staticmethod def from_symbol(symbol: str): return Direction(