Package: clubs
clubsclubs is a python library for running arbitrary configurations of community card poker games. This includes anything from simple Leduc orKuhnpoker to full n-playerNo Limit Texas Hold'emorPot Limit Omaha.InstallInstall usingpip install clubs. To enable webserver rendering (see example below), install usingpip install clubs[render].Exampleimportrandomimportclubsconfig=clubs.configs.NO_LIMIT_HOLDEM_SIX_PLAYERdealer=clubs.poker.Dealer(**config)obs=dealer.reset()whileTrue:call=obs['call']min_raise=obs['min_raise']max_raise=obs['max_raise']rand=random.random()ifrand<0.1:bet=0elifrand<0.80:bet=callelse:bet=random.randint(min_raise,max_raise)obs,rewards,done=dealer.step(bet)ifall(done):breakprint(rewards)ConfigurationThe type of poker game is defined using a configuration dictionary. Seeconfigs.pyfor some example configurations. A configuration dictionary has to have the following key value structure:num_playersint: maximum number of playersnum_streetsint: number of streetsblindsint or list of ints: the blind distribution starting from the button e.g. [0, 1, 2, 0, 0, 0] for a 6 player 1-2 gamea single int is expanded to the number of players, settings blinds=0 will result in no blinds [0, 0, 0, 0, 0, 0]antesint or list of ints: the ante distribution starting from the button, analog to the blind distributionsingle ints are expanded to the number of playersraise_sizesfloat or str or list of floats or str: the maximum raise size as a list of values, one for each streetoptions are ints (for fixed raise sizes), float('inf') (for no limit raise sizes) or 'pot' for pot limit raise sizessingle values are expanded to the number of streetsnum_raisesfloat or list of floats: the maximum number of raises for each streetoptions are ints (for a fixed number of bets per round) or float('inf') for unlimited number of raisessingle values are expanded to the number of streetsnum_suitsnumber of suits in the decknum_ranksnumber of ranks in the decknum_hole_cardsnumber of hole cards for each playernum_community_cardsnumber of community cards per streetnum_cards_for_handnumber of cards for a valid poker handmandatory_num_hole_cardsnumber of hole cards which must be used for a poker handstart_stackinitial stack sizeAPIclubs adopts theOpen AI gyminterface. Seeclubs gymfor a full clubs gym environment. To deal a new hand, calldealer.reset(), which returns a dictionary of observations for the current active player. To advance the game, calldealer.step({bet})with an integer bet size. Invalid bet sizes are always rounded to the nearest valid bet size. When the bet lies exactly between 2 valid bet sizes, it is always rounded down. For example, if the minimum raise size is 10 and the bet is 5, the bet is rounded down to 0, i.e. call or fold.Universal DeucesThe hand evaluator is heavily inspired by thedeuceslibrary. The basic logic is identical, but the evaluator and lookup table are generalized to work for any deck configuration with number of ranks <= 13 and number of suits <= 4 and poker hands with 5 or less cards. See the pokerREADMEfor further details.Some speed was sacrificed for the sake of better usability. Nonetheless, the evaluator is still quite fast on modern machines (Intel(R) Core(TM) i5-8250U):>>>importclubs>>>evaluator=clubs.poker.Evaluator(4,13,5)>>>avg_time=evaluator.speed_test()>>>print(f"Average time per evaluation:{avg_time}")Averagetimeperevaluation:1.3986515504075214e-06>>>print(f"Evaluations per second ={1.0/avg_time}")Evaluationspersecond=714974.362062254Visualize3 different render modes are available viadealer.render(). The default render mode uses a web front which gets exposed on localhost on a specified or random port.LimitationsEven though the library is designed to be as general as possible, it currently has a couple limitations:Only integer chip denominations are supportedThe evaluator only works for sub decks of the standard 52 card deck as well as a maximum of 5 card poker handsDraw and stud poker games are not supported