+
+
+
+class MapGeometry():
+
+ def get_directions(self):
+ directions = []
+ for name in dir(self):
+ if name[:5] == 'move_':
+ directions += [name[5:]]
+ return directions
+
+ def move(self, start_pos, direction):
+ mover = getattr(self, 'move_' + direction)
+ return mover(start_pos)
+
+
+
+class MapGeometryWithLeftRightMoves(MapGeometry):
+
+ def move_LEFT(self, start_pos):
+ return YX(start_pos.y, start_pos.x - 1)
+
+ def move_RIGHT(self, start_pos):
+ return YX(start_pos.y, start_pos.x + 1)
+
+
+
+class MapGeometrySquare(MapGeometryWithLeftRightMoves):
+
+ def move_UP(self, start_pos):
+ return YX(start_pos.y - 1, start_pos.x)
+
+ def move_DOWN(self, start_pos):
+ return YX(start_pos.y + 1, start_pos.x)