def get_nearby_positions(self, position, exclude_locations=None):
    """Return a list of available positions that are next to the given position."""
    all_positions = set(
        itertools.product(
            set(range(self.grid_size)), list(range(self.grid_size))))
    available_positions = all_positions - self._occupied_positions
    relative_positions = set(DIR_TO_DIR_VEC.keys())
    if exclude_locations is not None:
      relative_positions = relative_positions - set(exclude_locations)
    relative_directions = [DIR_TO_DIR_VEC[loc] for loc in relative_positions]
    nearby_positions = set([(position.column - dir[0], position.row - dir[1])
                            for dir in relative_directions])
    actual_available_positions = available_positions.intersection(
        nearby_positions)
    return actual_available_positions
Return a list of available positions that are next to the given position.
language/gscan/data/world.py