Package: pokerkit
PokerKit is an open-source Python library for simulating poker games and evaluating poker hands, developed by the University of Toronto Computer Poker Research Group. PokerKit supports an extensive array of poker variants and it provides a flexible architecture for users to define their custom games. These facilities are exposed via an intuitive unified high-level programmatic API. The library can be used in a variety of use cases, from poker AI development, and tool creation, to online poker casino implementation. PokerKit’s reliability has been established through static type checking, extensive doctests, and unit tests, achieving 99% code coverage.FeaturesExtensive poker game logic for major and minor poker variants.High-speed hand evaluations.Customizable game states and parameters.Robust implementation with static type checking and extensive unit tests and doctests.Dataset of over 10,000 hand histories.InstallationThe PokerKit library can be installed using pip:pipinstallpokerkitUsagesThe first televised million-dollar pot between Tom Dwan and Phil Ivey.Link:https://youtu.be/GnxFohpljqMSet up the game.frompokerkitimportAutomation,NoLimitTexasHoldemstate=NoLimitTexasHoldem.create_state(# Automations(Automation.ANTE_POSTING,Automation.BET_COLLECTION,Automation.BLIND_OR_STRADDLE_POSTING,Automation.HOLE_CARDS_SHOWING_OR_MUCKING,Automation.HAND_KILLING,Automation.CHIPS_PUSHING,Automation.CHIPS_PULLING,),True,# Uniform antes?500,# Antes(1000,2000),# Blinds or straddles2000,# Min-bet(1125600,2000000,553500),# Starting stacks3,# Number of players)Below are the pre-flop dealings and actions.state.deal_hole('Ac2d')# Iveystate.deal_hole('????')# Antoniusstate.deal_hole('7h6h')# Dwanstate.complete_bet_or_raise_to(7000)# Dwanstate.complete_bet_or_raise_to(23000)# Iveystate.fold()# Antoniusstate.check_or_call()# DwanBelow are the flop dealing and actions.state.burn_card('??')state.deal_board('Jc3d5c')state.complete_bet_or_raise_to(35000)# Iveystate.check_or_call()# DwanBelow are the turn dealing and actions.state.burn_card('??')state.deal_board('4h')state.complete_bet_or_raise_to(90000)# Iveystate.complete_bet_or_raise_to(232600)# Dwanstate.complete_bet_or_raise_to(1067100)# Iveystate.check_or_call()# DwanBelow is the river dealing.state.burn_card('??')state.deal_board('Jh')Below are the final stacks.print(state.stacks)# [572100, 1997500, 1109500]An all-in hand between Xuan and Phua.Link:https://youtu.be/QlgCcphLjaQfrompokerkitimportAutomation,NoLimitShortDeckHoldemstate=NoLimitShortDeckHoldem.create_state(# Automations(Automation.ANTE_POSTING,Automation.BET_COLLECTION,Automation.BLIND_OR_STRADDLE_POSTING,Automation.HOLE_CARDS_SHOWING_OR_MUCKING,Automation.HAND_KILLING,Automation.CHIPS_PUSHING,Automation.CHIPS_PULLING,),True,# Uniform antes?3000,# Antes{-1:3000},# Blinds or straddles3000,# Min-bet(495000,232000,362000,403000,301000,204000),# Starting stacks6,# Number of players)Below are the pre-flop dealings and actions.state.deal_hole('Th8h')# Badziakouskistate.deal_hole('QsJd')# Zhongstate.deal_hole('QhQd')# Xuanstate.deal_hole('8d7c')# Junstate.deal_hole('KhKs')# Phuastate.deal_hole('8c7h')# Koonstate.check_or_call()# Badziakouskistate.check_or_call()# Zhongstate.complete_bet_or_raise_to(35000)# Xuanstate.fold()# Junstate.complete_bet_or_raise_to(298000)# Phuastate.fold()# Koonstate.fold()# Badziakouskistate.fold()# Zhongstate.check_or_call()# XuanBelow is the flop dealing.state.burn_card('??')state.deal_board('9h6cKc')Below is the turn dealing.state.burn_card('??')state.deal_board('Jh')Below is the river dealing.state.burn_card('??')state.deal_board('Ts')Below are the final stacks.print(state.stacks)# [489000, 226000, 684000, 400000, 0, 198000]The largest online poker pot ever played between Patrik Antonius and Viktor
Blom.Link:https://youtu.be/UMBm66Id2AAfrompokerkitimportAutomation,PotLimitOmahaHoldemstate=PotLimitOmahaHoldem.create_state(# Automations(Automation.ANTE_POSTING,Automation.BET_COLLECTION,Automation.BLIND_OR_STRADDLE_POSTING,Automation.HOLE_CARDS_SHOWING_OR_MUCKING,Automation.HAND_KILLING,Automation.CHIPS_PUSHING,Automation.CHIPS_PULLING,),True,# Uniform antes?0,# Antes(500,1000),# Blinds or straddles1000,# Min-bet(1259450.25,678473.5),# Starting stacks2,# Number of players)Below are the pre-flop dealings and actions.state.deal_hole('Ah3sKsKh')# Antoniusstate.deal_hole('6d9s7d8h')# Blomstate.complete_bet_or_raise_to(3000)# Blomstate.complete_bet_or_raise_to(9000)# Antoniusstate.complete_bet_or_raise_to(27000)# Blomstate.complete_bet_or_raise_to(81000)# Antoniusstate.check_or_call()# BlomBelow are the flop dealing and actions.state.burn_card('??')state.deal_board('4s5c2h')state.complete_bet_or_raise_to(91000)# Antoniusstate.complete_bet_or_raise_to(435000)# Blomstate.complete_bet_or_raise_to(779000)# Antoniusstate.check_or_call()# BlomBelow is the turn dealing.state.burn_card('??')state.deal_board('5h')Below is the river dealing.state.burn_card('??')state.deal_board('9c')Below are the final stacks.print(state.stacks)# [1937923.75, 0.0]A bad beat between Yockey and Arieh.Link:https://youtu.be/pChCqb2FNxYfrompokerkitimportAutomation,FixedLimitDeuceToSevenLowballTripleDrawstate=FixedLimitDeuceToSevenLowballTripleDraw.create_state(# Automations(Automation.ANTE_POSTING,Automation.BET_COLLECTION,Automation.BLIND_OR_STRADDLE_POSTING,Automation.HOLE_CARDS_SHOWING_OR_MUCKING,Automation.HAND_KILLING,Automation.CHIPS_PUSHING,Automation.CHIPS_PULLING,),True,# Uniform antes?0,# Antes(75000,150000),# Blinds or straddles150000,# Small-bet300000,# Big-bet(1180000,4340000,5910000,10765000),# Starting stacks4,# Number of players)Below are the pre-flop dealings and actions.state.deal_hole('7h6c4c3d2c')# Yockeystate.deal_hole('??????????')# Huistate.deal_hole('??????????')# Espositostate.deal_hole('AsQs6s5c3c')# Ariehstate.fold()# Espositostate.complete_bet_or_raise_to()# Ariehstate.complete_bet_or_raise_to()# Yockeystate.fold()# Huistate.check_or_call()# AriehBelow are the first draw and actions.state.stand_pat_or_discard()# Yockeystate.stand_pat_or_discard('AsQs')# Ariehstate.burn_card('??')state.deal_hole('2hQh')# Ariehstate.complete_bet_or_raise_to()# Yockeystate.check_or_call()# AriehBelow are the second draw and actions.state.stand_pat_or_discard()# Yockeystate.stand_pat_or_discard('Qh')# Ariehstate.burn_card('??')state.deal_hole('4d')# Ariehstate.complete_bet_or_raise_to()# Yockeystate.check_or_call()# AriehBelow are the third draw and actions.state.stand_pat_or_discard()# Yockeystate.stand_pat_or_discard('6s')# Ariehstate.burn_card('??')state.deal_hole('7c')# Ariehstate.complete_bet_or_raise_to()# Yockeystate.check_or_call()# AriehBelow are the final stacks.print(state.stacks)# [0, 4190000, 5910000, 12095000]An example badugi hand from Wikipedia.Link:https://en.wikipedia.org/wiki/BadugifrompokerkitimportAutomation,FixedLimitBadugistate=FixedLimitBadugi.create_state(# Automations(Automation.ANTE_POSTING,Automation.BET_COLLECTION,Automation.BLIND_OR_STRADDLE_POSTING,Automation.HAND_KILLING,Automation.CHIPS_PUSHING,Automation.CHIPS_PULLING,),True,# Uniform antes?0,# Antes(1,2),# Blinds or straddles2,# Small-bet4,# Big-bet200,# Starting stacks4,# Number of players)Below are the pre-flop dealings and actions.state.deal_hole('????????')# Bobstate.deal_hole('????????')# Carolstate.deal_hole('????????')# Tedstate.deal_hole('????????')# Alicestate.fold()# Tedstate.check_or_call()# Alicestate.check_or_call()# Bobstate.check_or_call()# CarolBelow are the first draw and actions.state.stand_pat_or_discard('????')# Bobstate.stand_pat_or_discard('????')# Carolstate.stand_pat_or_discard('??')# Alicestate.burn_card('??')state.deal_hole('????')# Bobstate.deal_hole('????')# Carolstate.deal_hole('??')# Alicestate.check_or_call()# Bobstate.complete_bet_or_raise_to()# Carolstate.check_or_call()# Alicestate.check_or_call()# BobBelow are the second draw and actions.state.stand_pat_or_discard('??')# Bobstate.stand_pat_or_discard()# Carolstate.stand_pat_or_discard('??')# Alicestate.burn_card('??')state.deal_hole('??')# Bobstate.deal_hole('??')# Alicestate.check_or_call()# Bobstate.complete_bet_or_raise_to()# Carolstate.complete_bet_or_raise_to()# Alicestate.fold()# Bobstate.check_or_call()# CarolBelow are the third draw and actions.state.stand_pat_or_discard('??')# Carolstate.stand_pat_or_discard()# Alicestate.burn_card('??')state.deal_hole('??')# Carolstate.check_or_call()# Carolstate.complete_bet_or_raise_to()# Alicestate.check_or_call()# CarolBelow is the showdown.state.show_or_muck_hole_cards('2s4c6d9h')# Alicestate.show_or_muck_hole_cards('3s5d7c8h')# CarolBelow are the final stacks.print(state.stacks)# [196, 220, 200, 184]Testing and ValidationPokerKit has extensive test coverage, passes mypy static type checking with strict parameter, and has been validated through extensive use in real-life scenarios.ContributingContributions are welcome! Please read our Contributing Guide for more information.LicensePokerKit is distributed under the MIT license.CitingIf you use PokerKit in your research, please cite our library:@ARTICLE{10287546,author={Kim, Juho},journal={IEEE Transactions on Games},title={PokerKit: A Comprehensive Python Library for Fine-Grained Multi-Variant Poker Game Simulations},year={2023},volume={},number={},pages={1-8},doi={10.1109/TG.2023.3325637}}