From b2cc1e814c3dea3b2582c2b85726db387acfca3d Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sun, 17 Dec 2023 08:24:19 +0100 Subject: [PATCH] FIX Coordinate().getNeighbours() min/maxY FIX Coordinate() not hashable after implementing __eq__ --- src/tools/coordinate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/coordinate.py b/src/tools/coordinate.py index e5e78d5..a61988b 100644 --- a/src/tools/coordinate.py +++ b/src/tools/coordinate.py @@ -187,7 +187,7 @@ class Coordinate(tuple): nb_list = [(-1, 0), (1, 0), (0, -1), (0, 1)] for dx, dy in nb_list: - if minX <= self[0] + dx <= maxX and minY <= self[0] + dy <= maxY: + if minX <= self[0] + dx <= maxX and minY <= self[1] + dy <= maxY: yield self.__class__(self[0] + dx, self[1] + dy) else: if includeDiagonal: @@ -261,6 +261,9 @@ class Coordinate(tuple): else: return self.__class__(-self[0], -self[1], -self[2]) + def __hash__(self) -> int: + return hash((self[0], self[1], self[2])) + def __eq__(self, other: Coordinate | tuple) -> bool: if self[2] is None: return self[0] == other[0] and self[1] == other[1]