+ def get_neighbors(self, pos):
+ # DOWNLEFT, DOWNRIGHT, LEFT, RIGHT, UPLEFT, UPRIGHT (alphabetically)
+ neighbors = [None, None, None, None, None, None] # e, d, c, x, s, w
+ if pos[1] > 0:
+ neighbors[2] = [pos[0], pos[1] - 1]
+ if pos[1] < self.size[1] - 1:
+ neighbors[3] = [pos[0], pos[1] + 1]
+ # x, c, s, d, w, e # 3->0, 2->1, 5->4, 0->5
+ if pos[0] % 2 == 1:
+ if pos[0] > 0 and pos[1] > 0:
+ neighbors[4] = [pos[0] - 1, pos[1] - 1]
+ if pos[0] < self.size[0] - 1 and pos[1] > 0:
+ neighbors[0] = [pos[0] + 1, pos[1] - 1]
+ if pos[0] > 0:
+ neighbors[5] = [pos[0] - 1, pos[1]]
+ if pos[0] < self.size[0] - 1:
+ neighbors[1] = [pos[0] + 1, pos[1]]
+ else:
+ if pos[0] > 0 and pos[1] < self.size[1] - 1:
+ neighbors[5] = [pos[0] - 1, pos[1] + 1]
+ if pos[0] < self.size[0] - 1 and pos[1] < self.size[1] - 1:
+ neighbors[1] = [pos[0] + 1, pos[1] + 1]
+ if pos[0] > 0:
+ neighbors[4] = [pos[0] - 1, pos[1]]
+ if pos[0] < self.size[0] - 1:
+ neighbors[0] = [pos[0] + 1, pos[1]]
+ return neighbors
+
+
+class MapSquare(Map):
+
+ # The following is used nowhere, so not implemented.
+ #def are_neighbors(self, pos_1, pos_2):
+ # return abs(pos_1[0] - pos_2[0]) <= 1 and abs(pos_1[1] - pos_2[1] <= 1)
+
+ def move_UP(self, start_pos):
+ return [start_pos[0] - 1, start_pos[1]]
+
+ def move_DOWN(self, start_pos):
+ return [start_pos[0] + 1, start_pos[1]]