Esempio n. 1
0
    def test_get_new_blockers_1d_leduc(self):
        env_bldr = get_leduc_env_bldr()
        range_ = PokerRange(env_bldr=env_bldr)

        full_board = np.array([[2, 1]], dtype=np.int8)

        should_be = {
            Poker.PREFLOP: env_bldr.lut_holder.get_1d_cards(full_board[:0]),
            Poker.FLOP: env_bldr.lut_holder.get_1d_cards(full_board),
        }

        for _round in [Poker.FLOP]:
            _n = env_bldr.lut_holder.DICT_LUT_N_CARDS_OUT[
                Poker.FLOP] - env_bldr.lut_holder.DICT_LUT_N_CARDS_OUT[_round]

            if _round == Poker.FLOP:
                board_2d = np.copy(full_board)
            else:
                board_2d = np.concatenate(
                    (full_board[:env_bldr.lut_holder.
                                DICT_LUT_N_CARDS_OUT[_round]],
                     np.array(
                         [Poker.CARD_NOT_DEALT_TOKEN_2D for _ in range(_n)],
                         dtype=np.int8)))

            result = range_._get_new_blockers_1d(game_round=_round,
                                                 board_2d=board_2d)
            assert np.array_equal(a1=result, a2=should_be[_round])
Esempio n. 2
0
    def test_get_new_blockers_1d_holdem(self):
        env_bldr = get_holdem_env_bldr()

        range_ = PokerRange(env_bldr=env_bldr)

        full_board = np.array([[1, 2], [3, 3], [12, 1], [5, 2], [6, 0]],
                              dtype=np.int8)

        should_be = {
            Poker.PREFLOP: env_bldr.lut_holder.get_1d_cards(full_board[:0]),
            Poker.FLOP: env_bldr.lut_holder.get_1d_cards(full_board[0:3]),
            Poker.TURN: env_bldr.lut_holder.get_1d_cards(full_board[3:4]),
            Poker.RIVER: env_bldr.lut_holder.get_1d_cards(full_board[4:5]),
        }

        for _round in [Poker.PREFLOP, Poker.FLOP, Poker.TURN, Poker.RIVER]:
            _n = env_bldr.lut_holder.DICT_LUT_N_CARDS_OUT[Poker.RIVER] - \
                 env_bldr.lut_holder.DICT_LUT_N_CARDS_OUT[_round]

            if _round == Poker.RIVER:
                board_2d = np.copy(full_board)
            else:
                board_2d = np.concatenate(
                    (full_board[:env_bldr.lut_holder.
                                DICT_LUT_N_BOARD_BRANCHES[_round]],
                     np.array(
                         [Poker.CARD_NOT_DEALT_TOKEN_2D for _ in range(_n)],
                         dtype=np.int8)))

            result = range_._get_new_blockers_1d(game_round=_round,
                                                 board_2d=board_2d)
            assert np.array_equal(a1=result, a2=should_be[_round])