Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class direction(enum.Enum):
- '''Enumerate the cardinal (NEWS) and intercardinal directions.
- The enum values are vectors, and can be accessed via V.vector
- as well, for clarity.
- '''
- NORTH = vector(-1, 0)
- NORTH_EAST = vector(-1, 1)
- EAST = vector( 0, 1)
- SOUTH_EAST = vector( 1, 1)
- SOUTH = vector( 1, 0)
- SOUTH_WEST = vector( 1, -1)
- WEST = vector( 0, -1)
- NORTH_WEST = vector(-1, -1)
- @property
- def vector(self):
- return self.value
- def flip_ew(self):
- return {
- direction.NORTH_EAST: direction.NORTH_WEST,
- direction.EAST: direction.WEST,
- direction.SOUTH_EAST: direction.SOUTH_WEST,
- direction.SOUTH_WEST: direction.SOUTH_EAST,
- direction.WEST: direction.EAST,
- direction.NORTH_WEST: direction.NORTH_EAST,
- }.get(self, self)
- def flip_nw(self):
- return {
- direction.NORTH: direction.SOUTH,
- direction.NORTH_EAST: direction.SOUTH_EAST,
- direction.SOUTH_EAST: direction.NORTH_EAST,
- direction.SOUTH: direction.NORTH,
- direction.SOUTH_WEST: direction.NORTH_WEST,
- direction.NORTH_WEST: direction.SOUTH_WEST,
- }.get(self, self)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement