-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpos.py
28 lines (22 loc) · 947 Bytes
/
pos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations
from orientation import Orientation
class Pos:
def __init__(self, x: int, y: int, orientation: Orientation = Orientation.STANDING):
self.x = x
self.y = y
self.orientation = orientation
def __hash__(self):
return hash((self.x, self.y, self.orientation))
def __str__(self):
"""
String representation of position object (for easier debugging)
:return: Position object as string.
"""
return '[x:{}, y:{}, orientation:{}]'.format(self.x, self.y, self.orientation)
def __eq__(self, other: Pos) -> bool:
"""
Compare current position object with another.
:param other: The other position object.
:return: True if the two objects match in x, y coordinates as well as their orientation.
"""
return self.x == other.x and self.y == other.y and self.orientation == other.orientation