def get_next_potential_neighbours(self, gamemap: GameMap): self.square_stati[self.square_stati == self.Status.OLD_BOUNDARY] = self.Status.DONE self.square_stati[self.square_stati == self.Status.NEW_BOUNDARY] = self.Status.OLD_BOUNDARY grow_from_to_squares = [] for square in np.argwhere(self.square_stati == self.Status.OLD_BOUNDARY): for move in [(0, -1), (1, 0), (0, 1), (-1, 0)]: neighbour = ((square[0] + move[0]) % gamemap.height, (square[1] + move[1]) % gamemap.width) if not gamemap.is_mine(neighbour) and \ (self.square_stati[neighbour] == self.Status.UNKNOWN or self.square_stati[neighbour] == self.Status.NEW_BOUNDARY): grow_from_to_squares.append((tuple(square), neighbour)) self.square_stati[neighbour] = self.Status.NEW_BOUNDARY return grow_from_to_squares
def mark_borders_and_get_potential_territory(self, gamemap: GameMap): grow_from_to_squares = [] for square in gamemap.my_locations_list(): # for neighbour in gamemap.neighbours(square[0], square[1]): for move in [(0, -1), (1, 0), (0, 1), (-1, 0)]: # [(y + dy) % self.height][(x + dx) % self.width] neighbour = ((square[0] + move[0]) % gamemap.height, (square[1] + move[1]) % gamemap.width) if not gamemap.is_mine(neighbour): grow_from_to_squares.append((square, neighbour)) self.step_distances[square] = 0 self.square_stati[square] = self.Status.MY_BOUNDARY self.square_stati[neighbour] = self.Status.NEW_BOUNDARY return grow_from_to_squares