def test_observe(self): world = WorldTotalWatten() world.current_game_player_A_score = 1 world.current_game_player_B_score = 2 world.player_A_score = 14 world.player_B_score = 1 world.is_last_move_raise = True world.is_last_move_accepted_raise = True world.is_last_hand_raise_valid = False world.current_game_prize = 15 expected_player_A = [1, 0, 0, 1, 0, 0, 0, 0, 0, 0, # 110 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, # 120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 130 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, # 140 0, 0, 0, 0, 0, 0, 0, 1, 0, 0] # 150 expected_player_B = [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, # 110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 130 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, # 140 0, 0, 0, 0, 0, 0, 0, 1, 0, 0] # 150 observation_player_A = world.observe(1, self.agent) observation_player_B = world.observe(-1, self.agent) #testing last part of observation is correct np.testing.assert_array_equal(observation_player_A[32:82], np.array(expected_player_A).reshape((50, 1))) np.testing.assert_array_equal(observation_player_B[32:82], np.array(expected_player_B).reshape((50, 1)))
def test_observe(self): world = WorldTotalWatten() world.current_game_prize = 15 result = world.observe(1, self.agent) print(result)
def test_act_raise_points(self): world = WorldTotalWatten() world.current_player = -1 world.current_game_prize = 4 world.is_last_move_raise = False world.is_last_move_accepted_raise = False result, next_player = world.act(1, self.agent) self.assertEqual(result, "continue") self.assertEqual(next_player, 1) self.assertEqual(world.current_player, 1) self.assertEqual(world.current_game_prize, 5) self.assertEqual(world.is_last_move_raise, True) self.assertEqual(world.is_last_move_accepted_raise, False)
def test_act_fold(self): world = WorldTotalWatten() world.player_A_score = 4 world.player_B_score = 7 world.current_game_prize = 3 world.current_player = 1 world.distributing_cards_player = -1 world.is_last_move_raise = True result, next_player = world.act(total_watten.moves["fold_hand"], self.agent) self.assertEqual("end", result) self.assertEqual(7 + 2, world.player_B_score) self.assertEqual(-1, world.current_player) self.assertEqual(-1, next_player)
def test_assign_points_fold(self): # player -1 fold world = WorldTotalWatten() world.current_player = -1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = None world._assign_points_fold() self.assertEqual(world.player_A_score, 7) self.assertEqual(world.player_B_score, 8) # player 1 fold world = WorldTotalWatten() world.current_player = 1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = None world._assign_points_fold() self.assertEqual(world.player_A_score, 3) self.assertEqual(world.player_B_score, 12) # player 1 fold is last hand raise not valid world = WorldTotalWatten() world.current_player = 1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = False world._assign_points_fold() self.assertEqual(world.player_A_score, 7) self.assertEqual(world.player_B_score, 8) # player 1 fold is last hand raise valid world = WorldTotalWatten() world.current_player = 1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = True world._assign_points_fold() self.assertEqual(world.player_A_score, 3) self.assertEqual(world.player_B_score, 12) # player -1 fold is last hand raise not valid world = WorldTotalWatten() world.current_player = -1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = False world._assign_points_fold() self.assertEqual(world.player_A_score, 3) self.assertEqual(world.player_B_score, 12) # player -1 fold is last hand raise valid world = WorldTotalWatten() world.current_player = -1 world.current_game_prize = 5 world.player_A_score = 3 world.player_B_score = 8 world.is_last_hand_raise_valid = True world._assign_points_fold() self.assertEqual(world.player_A_score, 7) self.assertEqual(world.player_B_score, 8)