def test_get_cur_player(self): watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.current_player = 1 self.assertEqual(watten_game.get_cur_player(), 0) watten_game.trueboard.current_player = -1 self.assertEqual(watten_game.get_cur_player(), 1)
def test_make_move(self): watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.current_player = 1 self.assertEqual(watten_game.make_move(0), (0.0, 1)) watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.distributing_cards_player = -1 watten_game.trueboard.suit = 1 watten_game.trueboard.rank = 3 watten_game.trueboard.current_player = 1 watten_game.trueboard.current_game_player_A_score = 2 watten_game.trueboard.player_A_score = 15 watten_game.trueboard.played_cards = [0] watten_game.trueboard.player_A_hand = [1] self.assertEqual(watten_game.make_move(0), (1.0, 1)) watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.distributing_cards_player = 1 watten_game.trueboard.suit = 1 watten_game.trueboard.rank = 3 watten_game.trueboard.current_player = 1 watten_game.trueboard.current_game_player_A_score = 2 watten_game.trueboard.player_A_score = 15 watten_game.trueboard.played_cards = [0] watten_game.trueboard.player_A_hand = [1] self.assertEqual(watten_game.make_move(0), (1.0, 0))
def test_game_complete(self): # [36, 45, 14, 5, 25, 20, 46, 48, 1, 46, 48, 13, 35, 45, 15, 18, 7, 2, # 30, 46, 47, 36, 43, 27, 5, 46, 48, 6, 2, 22, 46, 47, 35, 44, 29, 8, 46, # 48, 18, 21, 27, 26, 14, 11, 9, 46, 48, 17, 34, 43, 10, 1, 46, 47, 41, # 42, 24, 17, 46, 48, 0, 14, 3, 29, 46, 48, 41, 45, 19, 8, 30, 24, 20, # 16, 34, 46, 47, 39, 44, 16, 30, 18, 46, 48, 21, 46, 47, 39, 43, 24, # 26, 14, 22, 29, 6, 5, 7] game = TotalWattenGame(self.agent, self.agent) world = WorldTotalWatten() world.init_world_to_state(1, -1, 0, 0, [25, 9, 1, 32, 14], [5, 13, 7, 10, 20], [], 0, 0, 2, False, False, None, 16, 28, None, None) game.trueboard = world cur_player = game.get_cur_player() self.assertEqual(cur_player, 0) moves = game.get_valid_moves_no_zeros() self.assertEqual(moves, [0, 1]) self.assertEqual(game.make_move(0), (0.0, 1)) cur_player = game.get_cur_player() self.assertEqual(cur_player, 1) moves = game.get_valid_moves_no_zeros() self.assertEqual(moves, [0, 1])
def test_clone(self): game = TotalWattenGame(self.agent, self.agent) world = WorldTotalWatten() world.init_world_to_state(1, -1, 0, 0, [25, 9, 1, 32, 14], [5, 13, 7, 10, 20], [], 0, 0, 2, False, False, None, 16, 28, None, None) game.trueboard = world clone_game = game.clone() obs_game = game.get_observation(game.get_cur_player()) obs_clone_game = clone_game.get_observation(clone_game.get_cur_player()) obs_str = game.get_observation_str(obs_game) clone_obs_str = clone_game.get_observation_str(obs_clone_game) self.assertEqual(obs_str, clone_obs_str)
def test_get_score(self): watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.current_player = 1 self.assertEqual(watten_game.get_score(1), 0.0) self.assertEqual(watten_game.get_score(0), 0.0) watten_game.trueboard.winning_player = 1 watten_game.trueboard.player_A_score = 15 self.assertEqual(watten_game.get_score(1), -1.0) self.assertEqual(watten_game.get_score(0), 1.0) watten_game = TotalWattenGame(self.agent, self.agent) watten_game.trueboard.current_player = -1 self.assertEqual(watten_game.get_score(1), 0.0) self.assertEqual(watten_game.get_score(0), 0.0) watten_game.trueboard.winning_player = -1 watten_game.trueboard.player_B_score = 15 self.assertEqual(watten_game.get_score(1), 1.0) self.assertEqual(watten_game.get_score(0), -1.0)
def test_get_observation_size(self): watten_game = TotalWattenGame(self.agent, self.agent) self.assertEqual(watten_game.get_observation_size(), (82, 1))
def test_get_action_size(self): watten_game = TotalWattenGame(self.agent, self.agent) self.assertEqual(watten_game.get_action_size(), 5)
def test_get_player_num(self): watten_game = TotalWattenGame(self.agent, self.agent) self.assertEqual(watten_game.get_players_num(), 2)