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)))
Exemplo n.º 2
0
    def test_get_valid_moves_last_move_raise(self):
        world = WorldTotalWatten()

        world.is_last_move_raise = True

        valid_moves = world.get_valid_moves()

        # after a raise a player can only accept it or fold
        self.assertEqual([2, 3], valid_moves)
Exemplo n.º 3
0
    def test_get_valid_moves_last_move_raise_last_hand(self):
        world = WorldTotalWatten()

        world.is_last_move_raise = True
        world.is_last_hand_raise_valid = True

        valid_moves = world.get_valid_moves()

        # after a raise in last hand a player can only accept, fold, or fold and verify conditions for raise in last hand
        self.assertEqual([2, 3, 4], valid_moves)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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)