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 = WattenSubGame()
        world = WorldSubWatten()
        world.init_world_to_state(1, -1, [25, 9, 1, 32, 14], [5, 13, 7, 10, 20], [], 0, 0, 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, [33, 34, 35, 36, 37, 38, 39, 40, 41])

        self.assertEqual(game.make_move(36), (0.0, 1))

        cur_player = game.get_cur_player()
        self.assertEqual(cur_player, 1)

        moves = game.get_valid_moves_no_zeros()
        self.assertEqual(moves, [42, 43, 44, 45])
    def test_get_valid_moves_declare_rank(self):
        world = WorldSubWatten()

        world.refresh()

        # opponent player declare the rank
        # valid moves: ALL RANKS
        valid_moves = world.get_valid_moves()
        self.assertEqual([33, 34, 35, 36, 37, 38, 39, 40, 41], valid_moves)
    def test_get_valid_moves_declare_suit(self):
        world = WorldSubWatten()

        world.rank = 5  # rank already chosen

        # current player declare the suit
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [42, 43, 44, 45])

        world.suit = 3

        valid_moves = world.get_valid_moves()

        self.assertEqual(len(valid_moves), 5)

        # no suit played - every move is allowed
        world.played_cards.append(watten.get_id(7, 2))
        world.current_player = 1
        world.player_A_hand = [
            watten.get_id(3, 2),
            watten.get_id(6, 3),
            watten.get_id(3, 0),
            watten.get_id(2, 0),
            watten.get_id(4, 1)
        ]

        valid_moves = world.get_valid_moves()

        self.assertEqual(valid_moves, [19, 30, 3, 2, 12])
    def test_act_pick_suit_2(self):
        world = WorldSubWatten()

        world.current_player = -1
        world.rank = 3

        result, next_player = world.act(42)

        self.assertEqual(result, "continue")
        self.assertEqual(next_player, 1)
        self.assertEqual(world.suit, 0)
    def test_is_blinde(self):
        world = WorldSubWatten()

        world.rank = 6
        world.suit = 2

        self.assertTrue(world.is_blinde(6))
        self.assertFalse(world.is_blinde(3))
        self.assertFalse(world.is_blinde(1))
        self.assertFalse(world.is_blinde(7))
    def test_get_valid_moves_declare_suit_rank_weli(self):
        world = WorldSubWatten()

        world.refresh()

        # when the chosen rank is weli, suit is automatically
        world.rank = 8
        world.suit = 3

        # opponent player declare the rank
        valid_moves = world.get_valid_moves()

        # if picked rank is weli, then it doesn't matter to declare a suit
        self.assertEqual(len(valid_moves), 5)
    def test_get_valid_moves_played_suit_only_rechte(self):
        world = WorldSubWatten()

        # suit has been played
        world.played_cards = []
        world.rank = 4
        world.suit = 3
        world.played_cards.append(watten.get_id(3, 3))
        world.current_player = 1
        world.player_A_hand = [
            watten.get_id(1, 2),
            watten.get_id(1, 0),
            watten.get_id(3, 0),
            watten.get_id(4, 3),
            watten.get_id(2, 2)
        ]

        valid_moves = world.get_valid_moves()

        self.assertEqual(valid_moves, [17, 1, 3, 28, 18])
    def test_is_game_end(self):
        world = WorldSubWatten()

        world.refresh()

        result = world.is_game_end()
        self.assertFalse(result)

        world.current_game_player_A_score = 3
        result = world.is_game_end()
        self.assertTrue(result)

        world.refresh()

        world.current_game_player_B_score = 2
        result = world.is_game_end()
        self.assertFalse(result)

        world.refresh()

        world.current_game_player_B_score = 3
        result = world.is_game_end()
        self.assertTrue(result)
    def test_is_rank_higher(self):
        world = WorldSubWatten()

        world.refresh()

        # weli played
        self.assertFalse(world.is_rank_higher(8, 0))
        self.assertFalse(world.is_rank_higher(8, 1))
        self.assertFalse(world.is_rank_higher(8, 2))
        self.assertFalse(world.is_rank_higher(8, 3))
        self.assertFalse(world.is_rank_higher(8, 4))
        self.assertFalse(world.is_rank_higher(8, 5))
        self.assertFalse(world.is_rank_higher(8, 6))
        self.assertFalse(world.is_rank_higher(8, 7))
        self.assertTrue(world.is_rank_higher(0, 8))
        self.assertTrue(world.is_rank_higher(1, 8))
        self.assertTrue(world.is_rank_higher(2, 8))
        self.assertTrue(world.is_rank_higher(3, 8))
        self.assertTrue(world.is_rank_higher(4, 8))
        self.assertTrue(world.is_rank_higher(5, 8))
        self.assertTrue(world.is_rank_higher(6, 8))
        self.assertTrue(world.is_rank_higher(7, 8))
        self.assertTrue(world.is_rank_higher(3, 8))

        # not weli
        self.assertTrue(world.is_rank_higher(6, 5))
        self.assertTrue(world.is_rank_higher(7, 1))
        self.assertFalse(world.is_rank_higher(1, 4))
        self.assertFalse(world.is_rank_higher(3, 6))
        self.assertFalse(world.is_rank_higher(4, 6))
        self.assertFalse(world.is_rank_higher(5, 6))
    def test_game_no_raise_player_A_starts(self):
        world = WorldSubWatten()
        world.LOG.setLevel(DEBUG)

        world.init_world_to_state(1, -1, [14, 30, 2, 28, 11], [4, 23, 31, 7, 22], [], 0, 0, 21, 26, None, None)

        # [40, 45, 29, 12, 28, 13, 26, 0, 33, 45,
        #  3, 25, 6, 16, 30, 14, 13, 1, 38, 43, 13, 5, 32, 3, 21, 27, 33, 42, 0,
        #  4, 30, 31, 23, 7, 29, 1, 25, 9, 33, 42, 9, 30, 14, 32, 7, 25, 34, 42,
        #  29, 7, 15, 19, 11, 17, 20, 27, 0, 2, 35, 44, 31, 4, 28, 1, 12, 3, 33,
        #  45, 24, 25, 7, 11, 14, 18, 37, 45, 2, 27, 3, 0, 8, 10, 6, 26, 33, 43,
        #  21, 22, 6, 10, 24, 14, 8, 16, 33, 42, 3, 0, 29, 17, 13, 31]
        world_copy = world.deepcopy()

        ######## MOVE ######## PICK RANK
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [33, 34, 35, 36, 37, 38, 39, 40, 41])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(36)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.rank = 3
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## PICK SUIT
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [42, 43, 44, 45])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(45)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.suit = 3
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [14, 30, 2, 28, 11])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(30)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.player_A_hand = [14, 2, 28, 11]
        world_copy.played_cards = [30]
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS AND WINS HAND
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [31])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(31)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.current_game_player_B_score = 1
        world_copy.player_B_hand = [4, 23, 7, 22]
        world_copy.played_cards = [30, 31]
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [4, 23, 7, 22])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(22)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.player_B_hand = [4, 23, 7]
        world_copy.played_cards = [30, 31, 22]
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS AND -1 WINS HAND
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [14, 2, 28, 11])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(2)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.player_A_hand = [14, 28, 11]
        world_copy.current_game_player_B_score = 2
        world_copy.played_cards = [30, 31, 22, 2]
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [4, 23, 7])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(23)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.player_B_hand = [4, 7]
        world_copy.played_cards = [30, 31, 22, 2, 23]
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS AND -1 WINS
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [14, 28, 11])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(14)
        self.assertEqual(outcome, "end")

        world_copy.current_game_player_A_score = 0
        world_copy.current_game_player_B_score = 3
        world_copy.player_A_hand = [28, 11]
        world_copy.played_cards = [30, 31, 22, 2, 23, 14]
        world_copy.current_player = 1
        world_copy.winning_player = -1
        self._compare_worlds(world, world_copy)
    def test_observe(self):
        world = WorldSubWatten()

        result = world.observe(1)

        print(result)
    def test_game_no_raise_player_B_starts(self):
        world = WorldSubWatten()
        world.LOG.setLevel(DEBUG)

        world.init_world_to_state(-1, 1, [3, 31, 27, 10, 29], [0, 9, 30, 25, 26], [], 0, 0, 15, 20, None, None)

        # [30, 29, 37, 45, 7, 10, 21, 19, 25, 24,
        # 33, 42, 8, 20, 32, 31, 24, 10, 0, 9, 36, 43, 23, 28, 12, 8, 31, 30, 34,
        #  43, 21, 23, 12, 17, 22, 24, 0, 4, 11, 25, 35, 44, 12, 1, 21, 17, 10,
        #  32, 34, 42, 19, 16, 3, 2, 20, 7, 13, 22, 11, 29, 37, 42, 8, 2, 3, 9, 5,
        #  4, 31, 16, 15, 32, 38, 44, 7, 24, 6, 22, 2, 23, 27, 9, 33, 42, 6, 16,
        #  17, 9, 13, 22, 34, 43, 19, 1, 5, 20, 10, 12, 17, 31, 22, 18, 35, 44,
        #  23, 20, 10, 25, 15, 14, 34, 43, 13, 12, 22, 10, 2, 1, 29, 18, 41, 45,
        #  5, 2, 14, 16, 27, 25]
        world_copy = world.deepcopy()

        ######## MOVE ######## -1 CHOOSE RANK
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [33, 34, 35, 36, 37, 38, 39, 40, 41])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(37)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.rank = 4
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 CHOOSE SUIT
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [42, 43, 44, 45])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(45)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.suit = 3
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [0, 9, 30, 25, 26])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(0)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.player_B_hand = [9, 30, 25, 26]
        world_copy.played_cards = [0]
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS CARD -1 WINS
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [3, 31, 27, 10, 29])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(10)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.player_A_hand = [3, 31, 27, 29]
        world_copy.played_cards = [0, 10]
        world_copy.current_game_player_B_score = 1
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [9, 30, 25, 26])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(25)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.player_B_hand = [9, 30, 26]
        world_copy.played_cards = [0, 10, 25]
        world_copy.current_player = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS CARD AND WINS
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [31, 27, 29])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(31)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, 1)

        world_copy.player_A_hand = [3, 27, 29]
        world_copy.played_cards = [0, 10, 25, 31]
        world_copy.current_player = 1
        world_copy.current_game_player_A_score = 1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## 1 PLAYS CARD
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [3, 27, 29])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(3)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.player_A_hand = [27, 29]
        world_copy.played_cards = [0, 10, 25, 31, 3]
        world_copy.current_player = -1
        self._compare_worlds(world, world_copy)

        ######## MOVE ######## -1 PLAYS CARD AND WINS
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [9, 30, 26])
        self._compare_worlds(world, world_copy)

        outcome, next_player = world.act(26)
        self.assertEqual(outcome, "continue")
        self.assertEqual(next_player, -1)

        world_copy.player_B_hand = [9, 30]
        world_copy.played_cards = [0, 10, 25, 31, 3, 26]
        world_copy.current_game_player_B_score = 2
        self._compare_worlds(world, world_copy)

        ######## MOVE ########
        valid_moves = world.get_valid_moves()
        self.assertEqual(valid_moves, [9, 30])
        self._compare_worlds(world, world_copy)
    def test_get_last_played_card(self):
        world = WorldSubWatten()
        world.played_cards = [4, 3, 2]
        last_played_card = world._get_last_played_card()
        self.assertEqual(last_played_card, 2)

        world = WorldSubWatten()
        world.played_cards = []
        last_played_card = world._get_last_played_card()
        self.assertEqual(last_played_card, None)

        world = WorldSubWatten()
        world.played_cards = [123]
        last_played_card = world._get_last_played_card()
        self.assertEqual(last_played_card, 123)

        world = WorldSubWatten()
        world.played_cards = [2, 8]
        last_played_card = world._get_last_played_card()
        self.assertEqual(last_played_card, 8)
    def test_observe(self):
        world = WorldSubWatten()
        world.current_player = 1
        world.distributing_cards_player = -1
        world.first_card_deck = 32
        world.last_card_deck = 26
        world.player_A_hand = [0, 1, 2, 3, 4]
        world.player_B_hand = [31, 30, 29, 28, 27]
        world.deck = list(range(33))
        world.deck = world.deck[5:26]
        world.rank = 8
        world.suit = 0
        world.played_cards = [10, 11, 12, 13, 14]
        world.current_game_player_A_score = 1
        world.current_game_player_B_score = 2

        expected_player_A = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 9
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 19
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 29
                             0, 0, 1, 0, 0, 0, 0, 0, 0, 0,  # 39
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 49
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 59
                             0, 0, 0, 0, 0, 0, 1, 1, 1, 1,  # 69
                             1, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 79
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 89
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 99
                             0, 0, 0, 0, 0, 0, 0, 1, 1, 0,  # 109
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 119
                             0, 0, 0, 0, 0, 0, 1, 0, 0, 0,  # 129
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 139
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 149
                             0, 0, 0, 0, 0, 1, 1, 1, 1, 1,  # 159
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 169
                             0, 0, 0, 0, 0, 0, 0, 0, 1, 0,  # 179
                             0, 1, 0, 0, 0, 0, 0, 1, 1, 1,  # 189
                             1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  # 199
                             1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  # 209
                             1, 1, 1, 1, 0, 0, 0, 0, 0, 1,  # 219
                             1]

        expected_player_B = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 9
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 19
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 29
                             0, 0, 1, 0, 0, 0, 0, 0, 0, 0,  # 39
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 49
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 1,  # 59
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 69
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 79
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 89
                             0, 0, 0, 1, 1, 1, 1, 1, 0, 0,  # 99
                             0, 0, 0, 0, 0, 0, 0, 1, 1, 0,  # 109
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 119
                             0, 0, 0, 0, 0, 0, 1, 0, 0, 0,  # 129
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 139
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 149
                             0, 0, 0, 0, 0, 1, 1, 1, 1, 1,  # 159
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  # 169
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 1,  # 179
                             1, 0, 1, 1, 1, 1, 1, 1, 1, 1,  # 189
                             1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  # 199
                             1, 1, 1, 1, 1, 1, 1, 1, 0, 0,  # 209
                             0, 0, 0, 0, 0, 0, 0, 0, 0, 1,  # 219
                             1]

        observation_player_A = world.observe(1)
        observation_player_B = world.observe(-1)
        np.testing.assert_array_equal(observation_player_A, np.array(expected_player_A).reshape((221, 1)))
        np.testing.assert_array_equal(observation_player_B, np.array(expected_player_B).reshape((221, 1)))
    def test_is_won(self):
        world = WorldSubWatten()

        world.refresh()

        world.current_game_player_A_score = 3
        result = world.is_won(-1)
        self.assertTrue(result)

        world.refresh()

        world.current_game_player_A_score = 3
        world.current_game_player_B_score = 3
        self.assertRaises(InconsistentStateError, world.is_won, 1)

        world.refresh()

        world.current_game_player_B_score = 3
        result = world.is_won(-1)
        self.assertFalse(result)

        world.refresh()

        world.current_game_player_B_score = 3
        result = world.is_won(1)
        self.assertTrue(result)
    def test_is_rechte(self):
        world = WorldSubWatten()

        world.rank = 6
        world.suit = 2

        self.assertTrue(world.is_rechte(6, 2))
        self.assertFalse(world.is_rechte(6, 3))
        self.assertFalse(world.is_rechte(3, 2))
        self.assertFalse(world.is_rechte(1, 0))

        world.rank = 4
        world.suit = 2

        self.assertFalse(world.is_rechte(8, -1))
        self.assertFalse(world.is_rechte(4, 3))
        self.assertFalse(world.is_rechte(2, 4))
        self.assertFalse(world.is_rechte(5, 1))
        self.assertTrue(world.is_rechte(4, 2))
 def test_refresh(self):
     world = WorldSubWatten()
    def test_act_unknown_move(self):
        world = WorldSubWatten()

        self.assertRaises(InvalidActionError, world.act, 46)
    def test_is_trumpf(self):
        world = WorldSubWatten()

        world.rank = 6
        world.suit = 2

        self.assertTrue(world.is_trumpf(4, 2))
        self.assertFalse(world.is_trumpf(5, 1))
        self.assertFalse(world.is_trumpf(6, 2))
        self.assertTrue(world.is_trumpf(0, 2))
        self.assertTrue(world.is_trumpf(1, 2))
        self.assertTrue(world.is_trumpf(3, 2))

        world.rank = 8
        world.suit = 3

        self.assertTrue(world.is_trumpf(1, 3))
        self.assertFalse(world.is_trumpf(5, 2))
    def test_remove_card_from_hand(self):
        world = WorldSubWatten()

        world.player_A_hand = [0, 1, 2, 3, 4]
        world.player_B_hand = [5, 6, 7, 8, 9]

        world._remove_card_from_hand(3, 1)
        self.assertTrue(world.player_A_hand, [0, 1, 2, 4])

        world._remove_card_from_hand(5, -1)
        self.assertTrue(world.player_A_hand, [6, 7, 8, 9])

        world._remove_card_from_hand(4, 1)
        self.assertTrue(world.player_A_hand, [0, 1, 2])

        world._remove_card_from_hand(8, -1)
        self.assertTrue(world.player_A_hand, [6, 7, 9])
    def test_compare_cards_rechte(self):
        world = WorldSubWatten()

        # if weli is rechte, then it should win
        world.rank = 8
        world.suit = 1

        card_id_one = watten.get_id(8, 3)
        card_id_two = watten.get_id(5, 1)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertFalse(world.compare_cards(card_id_two, card_id_one))

        world.rank = 5
        world.suit = 2

        card_id_one = watten.get_id(5, 2)
        card_id_two = watten.get_id(4, 2)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertFalse(world.compare_cards(card_id_two, card_id_one))

        # if weli is rechte, then it should win
        world.rank = 8
        world.suit = 1

        card_id_one = watten.get_id(4, 3)
        card_id_two = watten.get_id(8, 3)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
    def test_assign_points_single_hand_ended(self):
        # current player: 1
        world = WorldSubWatten()

        world.current_player = 1
        world.current_game_player_A_score = 1
        world.current_game_player_B_score = 2

        world._assign_points_move(True)

        self.assertEqual(world.current_game_player_A_score, 2)
        self.assertEqual(world.current_game_player_B_score, 2)

        world = WorldSubWatten()

        world.current_player = 1
        world.current_game_player_A_score = 1
        world.current_game_player_B_score = 2

        world._assign_points_move(False)

        self.assertEqual(world.current_game_player_A_score, 1)
        self.assertEqual(world.current_game_player_B_score, 3)

        # current player: 2
        world = WorldSubWatten()

        world.current_player = -1
        world.current_game_player_A_score = 1
        world.current_game_player_B_score = 2

        world._assign_points_move(True)

        self.assertEqual(world.current_game_player_A_score, 1)
        self.assertEqual(world.current_game_player_B_score, 3)

        world = WorldSubWatten()

        world.current_player = -1
        world.current_game_player_A_score = 1
        world.current_game_player_B_score = 2

        world._assign_points_move(False)

        self.assertEqual(world.current_game_player_A_score, 2)
        self.assertEqual(world.current_game_player_B_score, 2)
    def test_compare_cards_blinde(self):
        world = WorldSubWatten()

        world.refresh()

        world.rank = 4
        world.suit = 2

        card_id_one = watten.get_id(8, 3)
        card_id_two = watten.get_id(4, 1)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))

        world.rank = 5
        world.suit = 1

        card_id_one = watten.get_id(5, 3)
        card_id_two = watten.get_id(5, 1)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))

        world.rank = 8
        world.suit = 3

        card_id_one = watten.get_id(8, 3)
        card_id_two = watten.get_id(5, 1)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertFalse(world.compare_cards(card_id_two, card_id_one))

        world.rank = 4
        world.suit = 0

        card_id_one = watten.get_id(3, 0)
        card_id_two = watten.get_id(4, 1)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))
    def test_get_current_player_hand(self):
        world = WorldSubWatten()

        world.player_A_hand = [1, 2, 3]
        world.player_B_hand = [4, 5, 6]

        world.current_player = 1

        result = world._get_current_player_hand()
        self.assertEqual(result, [1, 2, 3])

        world = WorldSubWatten()

        world.player_A_hand = [1, 2, 3]
        world.player_B_hand = [4, 5, 6]

        world.current_player = -1

        result = world._get_current_player_hand()
        self.assertEqual(result, [4, 5, 6])
    def test_compare_cards_first_is_trumpfe(self):
        world = WorldSubWatten()

        world.refresh()

        # only the first card is trümpfe
        world.rank = 4
        world.suit = 2

        card_id_one = watten.get_id(3, 2)
        card_id_two = watten.get_id(5, 1)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))

        world.rank = 6
        world.suit = 1

        card_id_one = watten.get_id(4, 1)
        card_id_two = watten.get_id(7, 0)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))

        # both cards are trümpfe
        world.rank = 4
        world.suit = 2

        card_id_one = watten.get_id(6, 2)
        card_id_two = watten.get_id(5, 2)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertFalse(world.compare_cards(card_id_two, card_id_one))

        world.rank = 7
        world.suit = 1

        card_id_one = watten.get_id(5, 1)
        card_id_two = watten.get_id(6, 1)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))

        world.rank = 8
        world.suit = 3

        card_id_one = watten.get_id(8, 3)
        card_id_two = watten.get_id(2, 1)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
    def test_display(self):
        world = WorldSubWatten()

        world.display()
    def test_compare_cards_second_is_trumpfe(self):
        world = WorldSubWatten()

        world.refresh()

        world.rank = 4
        world.suit = 2

        card_id_one = watten.get_id(3, 1)
        card_id_two = watten.get_id(5, 2)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))

        world.rank = 7
        world.suit = 1

        card_id_one = watten.get_id(6, 3)
        card_id_two = watten.get_id(0, 1)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))

        world.rank = 8
        world.suit = 3

        card_id_one = watten.get_id(2, 1)
        card_id_two = watten.get_id(8, 3)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))

        world.rank = 2
        world.suit = 3

        card_id_one = watten.get_id(4, 3)
        card_id_two = watten.get_id(8, 3)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
    def test_compare_cards_no_trumpfe(self):
        world = WorldSubWatten()

        world.refresh()

        # different suit

        world.rank = 6
        world.suit = 1

        card_id_one = watten.get_id(5, 2)
        card_id_two = watten.get_id(3, 0)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))

        world.rank = 4
        world.suit = 0

        card_id_one = watten.get_id(6, 1)
        card_id_two = watten.get_id(7, 2)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))

        # same suit

        world.rank = 7
        world.suit = 2

        card_id_one = watten.get_id(5, 1)
        card_id_two = watten.get_id(3, 1)

        self.assertTrue(world.compare_cards(card_id_one, card_id_two))
        self.assertFalse(world.compare_cards(card_id_two, card_id_one))

        world.rank = 4
        world.suit = 0

        card_id_one = watten.get_id(1, 3)
        card_id_two = watten.get_id(5, 3)

        self.assertFalse(world.compare_cards(card_id_one, card_id_two))
        self.assertTrue(world.compare_cards(card_id_two, card_id_one))
    def test_game_no_raise_player_A_starts(self):
        world = WorldSubWatten()
        world.LOG.setLevel(DEBUG)

        world.init_world_to_state(-1, 1, [28, 29, 3, 15, 22],
                                  [19, 14, 7, 0, 11], [], 0, 0, 18, 21, None,
                                  None)

        # [39, 44, 0, 46, 48, 3, 29, 46, 48, 14, 11, 15]
        world_copy = world.deepcopy()

        ######## MOVE ########
        valid_moves = world.get_valid_moves()

        outcome, next_player = world.act(39)
        outcome, next_player = world.act(44)
        outcome, next_player = world.act(0)
        outcome, next_player = world.act(3)
        outcome, next_player = world.act(29)
        outcome, next_player = world.act(14)
        outcome, next_player = world.act(11)
        outcome, next_player = world.act(15)
        world.get_valid_moves()