コード例 #1
0
 def setUp(self):
     board = Board(3, 3, 5)
     board.set_board(np.array([
         [0, 1, 2],
         [np.nan, 0, 1],
         [np.nan, np.nan, np.nan]
     ]))
     self.board = board
     self.filler = Filler(1)
コード例 #2
0
class TestFiller(unittest.TestCase):
    def setUp(self):
        board = Board(3, 3, 5)
        board.set_board(
            np.array([[0, 1, 2], [np.nan, 0, 1], [np.nan, np.nan, np.nan]]))
        self.board = board
        self.filler = Filler(1)

    def test_filler(self):
        self.filler.move_and_fill(board=self.board)
        true = np.array([[3., 4., 0.], [1., 1., 2.], [0., 0., 1.]])
        answer = self.board.board
        self.assertEqual(true.tolist(), answer.tolist())
コード例 #3
0
 def setUp(self) -> None:
     self.filler = Filler()
コード例 #4
0
    def __init__(self,
                 step_add_immovable,
                 number_of_step_add_immovable,
                 match_counts_add_immovable,
                 number_of_match_counts_add_immovable,
                 immovable_move_,
                 n_of_match_counts_immov,
                 train_or_test,
                 no_legal_shuffle_or_new_,
                 rollout_len=100,
                 all_moves=True,
                 levels=None,
                 random_state=None):

        self.step_add_immovable = step_add_immovable
        self.number_of_step_add_immovable = number_of_step_add_immovable
        self.match_counts_add_immovable = match_counts_add_immovable
        self.number_of_match_counts_add_immovable = number_of_match_counts_add_immovable
        self.train_or_test = train_or_test
        self.rollout_len = rollout_len
        self.immovable_move = immovable_move_
        self.n_of_match_counts_immov = n_of_match_counts_immov
        self.no_legal_shuffle_or_new = no_legal_shuffle_or_new_

        self.random_state = random_state
        self.all_moves = all_moves
        self.levels = levels or Match3Levels(LEVELS)
        self.h = self.levels.h
        self.w = self.levels.w
        self.n_shapes = self.levels.n_shapes
        self.episode_counter = 0
        self.possible_move = random_state

        self.game = Game(
            rows=self.h,
            columns=self.w,
            n_shapes=self.n_shapes,
            length=3,
            all_moves=all_moves,
            random_state=self.random_state,
            no_legal_shuffle_or_new=self.no_legal_shuffle_or_new,
            number_of_match_counts_add_immovable=self.
            number_of_match_counts_add_immovable,
            train_or_test=self.train_or_test,
            filler=Filler(
                immovable_move=self.immovable_move,
                n_of_match_counts_immov=self.n_of_match_counts_immov,
                number_of_match_counts_add_immovable=self.
                number_of_match_counts_add_immovable,
                match_counts_add_immovable=self.match_counts_add_immovable))

        self.reset()[np.newaxis, :]
        self.renderer = Renderer(self.levels.h, self.levels.w, self.n_shapes)

        # setting observation space
        self.observation_space = spaces.Box(low=0,
                                            high=self.n_shapes,
                                            shape=(1, self.h, self.w),
                                            dtype=int)

        # setting actions space
        self.__match3_actions = self.get_available_actions()
        self.action_space = spaces.Discrete(len(self.__match3_actions))