lundi 18 mai 2020

Random number generator with exclusions

I have 9x9 numpy array filled with numbers [1;9]. I need to pick random position and assign this cell as 0 until I get certain difficulty value. By the way, my table should satisfy certain criterias and functions were checked on multiple tests.

while current_difficulty > self.difficulty:
        i = np.random.randint(0, self.board_size, 1)
        j = np.random.randint(0, self.board_size, 1)

        if self.unsolved[i, j] != 0 and self.__is_solvable():
            self.unsolved[i, j] = 0
            current_difficulty -= 1

What I need is get random pairs of values (i and j) that won’t repeat over time. Is there any functions I can use or methods I may implement? Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire