From 7428d95126ed66af83206036eb36712f85e562a2 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 18 Feb 2023 22:51:58 -0800 Subject: [PATCH] Fix the implementation of Point.is_adjacent_to --- erynrl/geometry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erynrl/geometry.py b/erynrl/geometry.py index aab95b8..f567ec5 100644 --- a/erynrl/geometry.py +++ b/erynrl/geometry.py @@ -33,7 +33,10 @@ class Point: bool True if this point is adjacent to the other point ''' - return (self.x in (other.x - 1, other.x + 1)) and (self.y in (other.y - 1, other.y + 1)) + if self == other: + return False + + return (self.x - 1 <= other.x <= self.x + 1) and (self.y - 1 <= other.y <= self.y + 1) def direction_to_adjacent_point(self, other: 'Point') -> Optional['Vector']: '''Given a point directly adjacent to `self`'''