Fix the implementation of Point.is_adjacent_to
This commit is contained in:
parent
06d34a527b
commit
7428d95126
1 changed files with 4 additions and 1 deletions
|
@ -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`'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue