Пример #1
0
    def generate_training_dataset(self, nb_raws, nb_smooth_max):
        """
        Procedure to create the dataset
        - start from perfect cube
        - smooth
        - record 3 things : state, number of coup, previous coup
        """
        smooth_sequence = np.random.randint(0, 12, nb_smooth_max)

        list_result = []

        for i in range(nb_raws):

            # we choose the number of random move
            nb_move = np.random.randint(1, nb_smooth_max)

            # initial state
            state = np.copy(self.perfect_rubik)

            # random move :
            smooth_sequence = np.random.randint(0, 12, nb_move)

            # we randomized the move
            for index_move in smooth_sequence:
                state = rb.rubik_cube().move_cube(index_move, state)

            last_move = smooth_sequence[-1]

            list_result.append([state, nb_move, self.inverse_move[last_move]])

        return list_result
Пример #2
0
 def xtest_move(self):
     self.rubik_ = rb.rubik_cube()
     i = 8
     self.rubik_.move(i)
     print('move : ' + str(i))
     unique, counts = np.unique(self.rubik_.state, return_counts=True)
     print(dict(zip(unique, counts)))
     print(self.rubik_.state)
Пример #3
0
    def xtest_inverse_ok(self):

        # we test for the 6 move that there inverse is corresponding with there real move !
        for i in [0, 1, 4, 5, 8, 9]:
            self.rubik_ = rb.rubik_cube()
            self.rubik_.move(i)
            self.rubik_.move(i + 2)
            np.testing.assert_array_equal(self.rubik_.state,
                                          self.rubik_.init_state)
Пример #4
0
    def xtest_move_all(self):
        self.rubik_ = rb.rubik_cube()
        print("testing all the move")

        for i in range(12):
            self.rubik_.move(i)
            print(i)
            unique, counts = np.unique(self.rubik_.state, return_counts=True)
            print(dict(zip(unique, counts)))
        print(self.rubik_.state)
Пример #5
0
    def xtest_random(self):
        self.rubik_ = rb.rubik_cube()

        for i in np.random.randint(0, 12, 1000):
            self.rubik_.move(i)

        # we check that there is 9 values for each color [0,1,2,3,4,5,6]
        unique, counts = np.unique(self.rubik_.state, return_counts=True)
        info_dict = dict(zip(unique, counts))

        for key in info_dict.keys():
            self.assertEqual(info_dict[key], 9)
Пример #6
0
    def smooth_rubik(self, rubik_array, nb_smooth):

        rubik_ = rb.rubik_cube(rubik_array)

        smooth_sequence = np.random.randint(0, 12, nb_smooth)
        self.smooth = smooth_sequence

        for i in smooth_sequence:

            rubik_.move(i)

        return rubik_
Пример #7
0
 def test_init(self):
     self.rubik_ = rb.rubik_cube()
     print(self.rubik_.init_state)
Пример #8
0
    def setUp(self):

        # init the rubik
        self.rubik_ = rb.rubik_cube()
Пример #9
0
 def __init__(self, nb_smooth=3):
     self.nb_smooth = nb_smooth
     self.perfect_rubik = rb.rubik_cube().init_state
Пример #10
0
 def __init__(self):
     self.perfect_rubik = rb.rubik_cube().init_state