def test_get_hand_rank_52_holdem(self): cpp_poker = CppHandeval() b = np.array([[2, 0], [2, 3], [11, 1], [10, 2], [11, 2]], dtype=np.int8) h = np.array([[11, 3], [5, 1]], dtype=np.int8) assert isinstance( cpp_poker.get_hand_rank_52_holdem(hand_2d=h, board_2d=b), int)
def test_get_hand_rank_52_holdem(self): cpp_poker = CppHandeval() b = np.array([[2, 0], [2, 3], [11, 1], [10, 2], [11, 2]], dtype=np.int8) h = np.array([[11, 3], [5, 1]], dtype=np.int8) handstr = cpp_poker.get_hand_rank_52_holdem(hand_2d=h, board_2d=b) assert handstr == 1240554
def get_hand_rank_52_holdem(self, n_reps): cpp_poker = CppHandeval() b = np.array([[2, 0], [2, 3], [11, 1], [10, 2], [11, 2]], dtype=np.int8) h = np.array([[11, 3], [5, 1]], dtype=np.int8) start = default_timer() for _ in range(n_reps): value = cpp_poker.get_hand_rank_52_holdem(hand_2d=h, board_2d=b) end = default_timer() print( f"time for get_hand_rank_52_holdem: {end - start} runs: {n_reps}")
class FlopHoldemRules: """ General rules of Texas Hold'em poker games """ N_HOLE_CARDS = 2 N_RANKS = 13 N_SUITS = 4 N_CARDS_IN_DECK = N_RANKS * N_SUITS RANGE_SIZE = PokerRange.get_range_size(n_hole_cards=N_HOLE_CARDS, n_cards_in_deck=N_CARDS_IN_DECK) BTN_IS_FIRST_POSTFLOP = False N_FLOP_CARDS = 5 N_TURN_CARDS = 0 N_RIVER_CARDS = 0 N_TOTAL_BOARD_CARDS = N_FLOP_CARDS ALL_ROUNDS_LIST = [Poker.PREFLOP, Poker.FLOP] SUITS_MATTER = True ROUND_BEFORE = { Poker.PREFLOP: Poker.PREFLOP, Poker.FLOP: Poker.PREFLOP, Poker.TURN: None, Poker.RIVER: None, } ROUND_AFTER = { Poker.PREFLOP: Poker.FLOP, Poker.FLOP: None, Poker.TURN: None, Poker.RIVER: None, } RANK_DICT = { Poker.CARD_NOT_DEALT_TOKEN_1D: "", 0: "2", 1: "3", 2: "4", 3: "5", 4: "6", 5: "7", 6: "8", 7: "9", 8: "T", 9: "J", 10: "Q", 11: "K", 12: "A" } SUIT_DICT = { Poker.CARD_NOT_DEALT_TOKEN_1D: "", 0: "h", 1: "d", 2: "s", 3: "c" } STRING = "FLOP_HOLDEM_RULES" def __init__(self): from PokerRL.game._.cpp_wrappers.CppHandeval import CppHandeval self._clib = CppHandeval() def get_hand_rank_all_hands_on_given_boards(self, boards_1d, lut_holder): """ for docs refer to PokerEnv """ return self._clib.get_hand_rank_all_hands_on_given_boards_52_holdem( boards_1d=boards_1d, lut_holder=lut_holder) def get_hand_rank(self, hand_2d, board_2d): """ for docs refer to PokerEnv """ return self._clib.get_hand_rank_52_holdem(hand_2d=hand_2d, board_2d=board_2d) @classmethod def get_lut_holder(cls): from PokerRL.game._.look_up_table import LutHolderHoldem return LutHolderHoldem(cls)