pokerkit 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pokerkit-0.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 University of Toronto Computer Poker Research Group
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,433 @@
1
+ Metadata-Version: 2.1
2
+ Name: pokerkit
3
+ Version: 0.0.0
4
+ Summary: A Python package for various poker tools
5
+ Home-page: https://github.com/uoftcprg/pokerkit
6
+ Author: University of Toronto Computer Poker Research Group
7
+ Author-email: uoftcprg@outlook.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://pokerkit.readthedocs.io/en/latest/
10
+ Project-URL: Source, https://github.com/uoftcprg/pokerkit
11
+ Project-URL: Tracker, https://github.com/uoftcprg/pokerkit/issues
12
+ Keywords: poker,nlhe,ai,game,game theory,libratus,modicum
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Topic :: Education
17
+ Classifier: Topic :: Games/Entertainment
18
+ Classifier: Topic :: Games/Entertainment :: Board Games
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python
24
+ Classifier: Programming Language :: Python :: 3
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/x-rst
30
+ License-File: LICENSE
31
+
32
+ ========
33
+ PokerKit
34
+ ========
35
+
36
+ ``PokerKit`` is an open-source Python library for simulating poker games and
37
+ evaluating poker hands, developed by the University of Toronto Computer Poker
38
+ Research Group. It provides extensive support for all major and minor poker
39
+ variants, offers a high level of control over game states, and supports
40
+ high-speed hand evaluations.
41
+
42
+ **Installation**
43
+ ----------------
44
+
45
+ The ``PokerKit`` library can be installed using pip:
46
+
47
+ .. code-block:: bash
48
+
49
+ pip install pokerkit
50
+
51
+ **Features**
52
+ ------------
53
+
54
+ * Extensive poker game logic for major and minor poker variants
55
+ * High-speed hand evaluations
56
+ * Customizable game states and parameters
57
+ * Robust implementation with extensive unit tests and doctests
58
+ * Ability to simulate famous hands from poker history
59
+
60
+ **Usage**
61
+ ---------
62
+
63
+ Below shows the first televised million dollar pot between Tom Dwan and Phil
64
+ Ivey.
65
+
66
+ Link: https://youtu.be/GnxFohpljqM
67
+
68
+ .. code-block:: python
69
+
70
+ from pokerkit import Automation, NoLimitTexasHoldem
71
+
72
+ state = NoLimitTexasHoldem.create_state(
73
+ (
74
+ Automation.ANTE_POSTING,
75
+ Automation.BET_COLLECTION,
76
+ Automation.BLIND_OR_STRADDLE_POSTING,
77
+ Automation.CARD_BURNING,
78
+ Automation.HOLE_CARDS_SHOWING_OR_MUCKING,
79
+ Automation.HAND_KILLING,
80
+ Automation.CHIP_PUSHING,
81
+ Automation.CHIP_PULLING,
82
+ ),
83
+ True,
84
+ 500,
85
+ (1000, 2000),
86
+ 2000,
87
+ (1125600, 2000000, 553500),
88
+ 3,
89
+ )
90
+
91
+ # Below shows the pre-flop dealings and actions.
92
+
93
+ state.deal_hole('Ac2d') # Ivey
94
+ state.deal_hole('5h7s') # Antonius*
95
+ state.deal_hole('7h6h') # Dwan
96
+
97
+ state.complete_bet_or_raise_to(7000) # Dwan
98
+ state.complete_bet_or_raise_to(23000) # Ivey
99
+ state.fold() # Antonius
100
+ state.check_or_call() # Dwan
101
+
102
+ # Below shows the flop dealing and actions.
103
+
104
+ state.deal_board('Jc3d5c')
105
+
106
+ state.complete_bet_or_raise_to(35000) # Ivey
107
+ state.check_or_call() # Dwan
108
+
109
+ # Below shows the turn dealing and actions.
110
+
111
+ state.deal_board('4h')
112
+
113
+ state.complete_bet_or_raise_to(90000) # Ivey
114
+ state.complete_bet_or_raise_to(232600) # Dwan
115
+ state.complete_bet_or_raise_to(1067100) # Ivey
116
+ state.check_or_call() # Dwan
117
+
118
+ # Below shows the river dealing.
119
+
120
+ state.deal_board('Jh')
121
+
122
+ # Below shows the final stacks.
123
+
124
+ print(state.stacks) # [572100, 1997500, 1109500]
125
+
126
+ Below shows an all-in hand between Xuan and Phua.
127
+
128
+ Link: https://youtu.be/QlgCcphLjaQ
129
+
130
+ .. code-block:: python
131
+
132
+ from pokerkit import Automation, NoLimitShortDeckHoldem
133
+
134
+ state = NoLimitShortDeckHoldem.create_state(
135
+ (
136
+ Automation.ANTE_POSTING,
137
+ Automation.BET_COLLECTION,
138
+ Automation.BLIND_OR_STRADDLE_POSTING,
139
+ Automation.CARD_BURNING,
140
+ Automation.HOLE_CARDS_SHOWING_OR_MUCKING,
141
+ Automation.HAND_KILLING,
142
+ Automation.CHIPS_PUSHING,
143
+ Automation.CHIPS_PULLING,
144
+ ),
145
+ True,
146
+ 3000,
147
+ {-1: 3000},
148
+ 3000,
149
+ (495000, 232000, 362000, 403000, 301000, 204000),
150
+ 6,
151
+ )
152
+
153
+ # Below shows the pre-flop dealings and actions.
154
+
155
+ state.deal_hole('Th8h') # Badziakouski
156
+ state.deal_hole('QsJd') # Zhong
157
+ state.deal_hole('QhQd') # Xuan
158
+ state.deal_hole('8d7c') # Jun
159
+ state.deal_hole('KhKs') # Phua
160
+ state.deal_hole('8c7h') # Koon
161
+
162
+ state.check_or_call() # Badziakouski
163
+ state.check_or_call() # Zhong
164
+ state.complete_bet_or_raise_to(35000) # Xuan
165
+ state.fold() # Jun
166
+ state.complete_bet_or_raise_to(298000) # Phua
167
+ state.fold() # Koon
168
+ state.fold() # Badziakouski
169
+ state.fold() # Zhong
170
+ state.check_or_call() # Xuan
171
+
172
+ # Below shows the flop dealing.
173
+
174
+ state.deal_board('9h6cKc')
175
+
176
+ # Below shows the turn dealing.
177
+
178
+ state.deal_board('Jh')
179
+
180
+ # Below shows the river dealing.
181
+
182
+ state.deal_board('Ts')
183
+
184
+ # Below show the final stacks.
185
+
186
+ print(state.stacks) # [489000, 226000, 684000, 400000, 0, 198000]
187
+
188
+ Below shows the largest online poker pot every played between
189
+ Patrik Antonius and Viktor Blom.
190
+
191
+ Link: https://youtu.be/UMBm66Id2AA
192
+
193
+ .. code-block:: python
194
+
195
+ from pokerkit import Automation, PotLimitOmahaHoldem
196
+
197
+ state = PotLimitOmahaHoldem.create_state(
198
+ (
199
+ Automation.ANTE_POSTING,
200
+ Automation.BET_COLLECTION,
201
+ Automation.BLIND_OR_STRADDLE_POSTING,
202
+ Automation.CARD_BURNING,
203
+ Automation.HOLE_CARDS_SHOWING_OR_MUCKING,
204
+ Automation.HAND_KILLING,
205
+ Automation.CHIPS_PUSHING,
206
+ Automation.CHIPS_PULLING,
207
+ ),
208
+ True,
209
+ None,
210
+ (50000, 100000),
211
+ 2000,
212
+ (125945025, 67847350),
213
+ 2,
214
+ )
215
+
216
+ # Below shows the pre-flop dealings and actions.
217
+
218
+ state.deal_hole('Ah3sKsKh') # Antonius
219
+ state.deal_hole('6d9s7d8h') # Blom
220
+
221
+ state.complete_bet_or_raise_to(300000) # Blom
222
+ state.complete_bet_or_raise_to(900000) # Antonius
223
+ state.complete_bet_or_raise_to(2700000) # Blom
224
+ state.complete_bet_or_raise_to(8100000) # Antonius
225
+ state.check_or_call() # Blom
226
+
227
+ # Below shows the flop dealing and actions.
228
+
229
+ state.deal_board('4s5c2h')
230
+
231
+ state.complete_bet_or_raise_to(9100000) # Antonius
232
+ state.complete_bet_or_raise_to(43500000) # Blom
233
+ state.complete_bet_or_raise_to(77900000) # Antonius
234
+ state.check_or_call() # Blom
235
+
236
+ # Below shows the turn dealing.
237
+
238
+ state.deal_board('5h')
239
+
240
+ # Below shows the river dealing.
241
+
242
+ state.deal_board('9c')
243
+
244
+ # Below show the final stacks.
245
+
246
+ print(state.stacks) # [193792375, 0]
247
+
248
+ Below shows a bad beat between Yockey and Arieh.
249
+
250
+ Link: https://youtu.be/pChCqb2FNxY
251
+
252
+ .. code-block:: python
253
+
254
+ from pokerkit import Automation, FixedLimitDeuceToSevenLowballTripleDraw
255
+
256
+ state = FixedLimitDeuceToSevenLowballTripleDraw.create_state(
257
+ (
258
+ Automation.ANTE_POSTING,
259
+ Automation.BET_COLLECTION,
260
+ Automation.BLIND_OR_STRADDLE_POSTING,
261
+ Automation.CARD_BURNING,
262
+ Automation.HOLE_CARDS_SHOWING_OR_MUCKING,
263
+ Automation.HAND_KILLING,
264
+ Automation.CHIP_PUSHING,
265
+ Automation.CHIP_PULLING,
266
+ ),
267
+ True,
268
+ None,
269
+ (75000, 150000),
270
+ 150000,
271
+ 300000,
272
+ (1180000, 4340000, 5910000, 10765000),
273
+ 4,
274
+ )
275
+
276
+ # Below shows the pre-flop dealings and actions.
277
+
278
+ state.deal_hole('7h6c4c3d2c') # Yockey
279
+ state.deal_hole('JsJcJdJhTs') # Hui*
280
+ state.deal_hole('KsKcKdKhTh') # Esposito*
281
+ state.deal_hole('AsQs6s5c3c') # Arieh
282
+
283
+ state.fold() # Esposito
284
+ state.complete_bet_or_raise_to() # Arieh
285
+ state.complete_bet_or_raise_to() # Yockey
286
+ state.fold() # Hui
287
+ state.check_or_call() # Arieh
288
+
289
+ # Below shows the first draw and actions.
290
+
291
+ state.stand_pat_or_discard() # Yockey
292
+ state.stand_pat_or_discard('AsQs') # Arieh
293
+ state.deal_hole('2hQh') # Arieh
294
+
295
+ state.complete_bet_or_raise_to() # Yockey
296
+ state.check_or_call() # Arieh
297
+
298
+ # Below shows the second draw and actions.
299
+
300
+ state.stand_pat_or_discard() # Yockey
301
+ state.stand_pat_or_discard('Qh') # Arieh
302
+ state.deal_hole('4d') # Arieh
303
+
304
+ state.complete_bet_or_raise_to() # Yockey
305
+ state.check_or_call() # Arieh
306
+
307
+ # Below shows the third draw and actions.
308
+
309
+ state.stand_pat_or_discard() # Yockey
310
+ state.stand_pat_or_discard('6s') # Arieh
311
+ state.deal_hole('7c') # Arieh
312
+
313
+ state.complete_bet_or_raise_to() # Yockey
314
+ state.check_or_call() # Arieh
315
+
316
+ # Below show the final stacks.
317
+
318
+ print(state.stacks) # [0, 4190000, 5910000, 12095000]
319
+
320
+ Below shows an example badugi hand from Wikipedia.
321
+
322
+ Link: https://en.wikipedia.org/wiki/Badugi
323
+
324
+ .. code-block:: python
325
+
326
+ from pokerkit import Automation, FixedLimitBadugi
327
+
328
+ state = FixedLimitBadugi.create_state(
329
+ (
330
+ Automation.ANTE_POSTING,
331
+ Automation.BET_COLLECTION,
332
+ Automation.BLIND_OR_STRADDLE_POSTING,
333
+ Automation.CARD_BURNING,
334
+ Automation.HOLE_CARDS_SHOWING_OR_MUCKING,
335
+ Automation.HAND_KILLING,
336
+ Automation.CHIPS_PUSHING,
337
+ Automation.CHIPS_PULLING,
338
+ ),
339
+ True,
340
+ None,
341
+ (1, 2),
342
+ 2,
343
+ 4,
344
+ 200,
345
+ 4,
346
+ )
347
+
348
+ # Below shows the pre-flop dealings and actions.
349
+
350
+ state.deal_hole('As4hJcKh') # Bob*
351
+ state.deal_hole('3s5d7s8s') # Carol*
352
+ state.deal_hole('KsKdQsQd') # Ted*
353
+ state.deal_hole('2s4c6dKc') # Alice*
354
+
355
+ state.fold() # Ted
356
+ state.check_or_call() # Alice
357
+ state.check_or_call() # Bob
358
+ state.check_or_call() # Carol
359
+
360
+ # Below shows the first draw and actions.
361
+
362
+ state.stand_pat_or_discard('JcKh') # Bob*
363
+ state.stand_pat_or_discard('7s8s') # Carol*
364
+ state.stand_pat_or_discard('Kc') # Alice*
365
+ state.deal_hole('TcJs') # Bob*
366
+ state.deal_hole('7cTh') # Carol*
367
+ state.deal_hole('Qc') # Alice*
368
+
369
+ state.check_or_call() # Bob
370
+ state.complete_bet_or_raise_to() # Carol
371
+ state.check_or_call() # Alice
372
+ state.check_or_call() # Bob
373
+
374
+ # Below shows the second draw and actions.
375
+
376
+ state.stand_pat_or_discard('Js') # Bob*
377
+ state.stand_pat_or_discard() # Carol*
378
+ state.stand_pat_or_discard('Qc') # Alice*
379
+ state.deal_hole('Ts') # Bob*
380
+ state.deal_hole('9h') # Alice*
381
+
382
+ state.check_or_call() # Bob
383
+ state.complete_bet_or_raise_to() # Carol
384
+ state.complete_bet_or_raise_to() # Alice
385
+ state.fold() # Bob
386
+ state.check_or_call() # Carol
387
+
388
+ # Below shows the third draw and actions.
389
+
390
+ state.stand_pat_or_discard('Th') # Carol*
391
+ state.stand_pat_or_discard() # Alice*
392
+ state.deal_hole('8h') # Carol*
393
+
394
+ state.check_or_call() # Carol
395
+ state.complete_bet_or_raise_to() # Alice
396
+ state.check_or_call() # Carol
397
+
398
+ # Below show the final stacks.
399
+
400
+ print(state.stacks) # [196, 220, 200, 184]
401
+
402
+ **Testing and Validation**
403
+ --------------------------
404
+
405
+ ``PokerKit`` has extensive test coverage, passes mypy static type checking with
406
+ strict parameter, and has been validated through extensive use in real-life
407
+ scenarios.
408
+
409
+ **Contributing**
410
+ ----------------
411
+
412
+ Contributions are welcome! Please read our
413
+ `Contributing Guide <CONTRIBUTING.rst>`_ for more information.
414
+
415
+ **License**
416
+ -----------
417
+
418
+ ``PokerKit`` is distributed under the MIT license. See `LICENSE <LICENSE>`_ for
419
+ more information.
420
+
421
+ **Citing**
422
+ ----------
423
+
424
+ If you use ``PokerKit`` in your research, please cite our library:
425
+
426
+ .. code-block:: bibtex
427
+
428
+ @misc{pokerkit,
429
+ title={PokerKit: An Open-Source Python Library for Poker Simulations and Hand Evaluations},
430
+ author={Your name here},
431
+ year={2023},
432
+ url={https://github.com/uoftcprg/pokerkit}
433
+ }