1 2 3 4 5 6 7 8 9 10 11 12
| def make_candidate_data(self):
"""
Generates "neighbor" board by randomly picking
a square, then swapping two small squares within.
"""
new_data = deepcopy(self.data)
block = randint(0,8)
num_in_block = len(self.get_block_indices(block, ignore_originals=True))
random_squares = sample(range(num_in_block),2)
square1, square2 = [self.get_block_indices(block, ignore_originals=True)[ind] for ind in random_squares] <<<<------------
new_data[square1], new_data[square2] = new_data[square2], new_data[square1]
return new_data |