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_get_valid_moves_last_move_accepted_raise(self): world = WorldTotalWatten() world.is_last_move_accepted_raise = True valid_moves = world.get_valid_moves() # after an accepted raise a player can't raise again self.assertNotIn(1, valid_moves)
def test_act_accept_raise(self): world = WorldTotalWatten() world.current_player = 1 world.is_last_move_accepted_raise = False world.is_last_move_raise = True result, next_player = world.act(3, self.agent) self.assertEqual(result, "continue") self.assertEqual(next_player, -1) self.assertEqual(world.is_last_move_raise, False) self.assertEqual(world.is_last_move_accepted_raise, True)
def test_best_move_declares_rank_1(self): world = WorldTotalWatten() world.current_player = 1 world.is_last_move_accepted_raise = True world.is_last_move_raise = False result, next_player = world.act(0, self.agent) self.assertEqual(result, "continue") self.assertEqual(next_player, -1) self.assertIsNotNone(world.rank) self.assertEqual(world.is_last_move_raise, False) self.assertEqual(False, world.is_last_move_accepted_raise)
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)