Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. class direction(enum.Enum):
  2. '''Enumerate the cardinal (NEWS) and intercardinal directions.
  3.  
  4. The enum values are vectors, and can be accessed via V.vector
  5. as well, for clarity.
  6.  
  7. '''
  8. NORTH = vector(-1, 0)
  9. NORTH_EAST = vector(-1, 1)
  10. EAST = vector( 0, 1)
  11. SOUTH_EAST = vector( 1, 1)
  12. SOUTH = vector( 1, 0)
  13. SOUTH_WEST = vector( 1, -1)
  14. WEST = vector( 0, -1)
  15. NORTH_WEST = vector(-1, -1)
  16.  
  17. @property
  18. def vector(self):
  19. return self.value
  20.  
  21. def flip_ew(self):
  22. return {
  23. direction.NORTH_EAST: direction.NORTH_WEST,
  24. direction.EAST: direction.WEST,
  25. direction.SOUTH_EAST: direction.SOUTH_WEST,
  26. direction.SOUTH_WEST: direction.SOUTH_EAST,
  27. direction.WEST: direction.EAST,
  28. direction.NORTH_WEST: direction.NORTH_EAST,
  29. }.get(self, self)
  30.  
  31. def flip_nw(self):
  32. return {
  33. direction.NORTH: direction.SOUTH,
  34. direction.NORTH_EAST: direction.SOUTH_EAST,
  35. direction.SOUTH_EAST: direction.NORTH_EAST,
  36. direction.SOUTH: direction.NORTH,
  37. direction.SOUTH_WEST: direction.NORTH_WEST,
  38. direction.NORTH_WEST: direction.SOUTH_WEST,
  39. }.get(self, self)
  40.  
  41.  
  42.  
  43. 
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement