pokerkit 0.7.7.dev0__tar.gz → 0.7.8__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.
Files changed (30) hide show
  1. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/PKG-INFO +1 -1
  2. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/analysis.py +12 -5
  3. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/games.py +1 -1
  4. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/state.py +50 -4
  5. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_analysis.py +36 -1
  6. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_state.py +76 -0
  7. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit.egg-info/PKG-INFO +1 -1
  8. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/setup.py +1 -1
  9. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/LICENSE +0 -0
  10. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/README.rst +0 -0
  11. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/__init__.py +0 -0
  12. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/hands.py +0 -0
  13. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/lookups.py +0 -0
  14. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/notation.py +0 -0
  15. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/py.typed +0 -0
  16. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/__init__.py +0 -0
  17. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_games.py +0 -0
  18. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_lookups.py +0 -0
  19. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_notation.py +0 -0
  20. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_papers.py +0 -0
  21. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_rules.py +0 -0
  22. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_utilities.py +0 -0
  23. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_wsop/__init__.py +0 -0
  24. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_wsop/test_2023_43_5.py +0 -0
  25. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/tests/test_wsop/test_2023_54_4.py +0 -0
  26. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit/utilities.py +0 -0
  27. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit.egg-info/SOURCES.txt +0 -0
  28. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit.egg-info/dependency_links.txt +0 -0
  29. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/pokerkit.egg-info/top_level.txt +0 -0
  30. {pokerkit-0.7.7.dev0 → pokerkit-0.7.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pokerkit
3
- Version: 0.7.7.dev0
3
+ Version: 0.7.8
4
4
  Summary: An open-source Python library for poker game simulations, hand evaluations, and statistical analysis
5
5
  Home-page: https://github.com/uoftcprg/pokerkit
6
6
  Author: Universal, Open, Free, and Transparent Computer Poker Research Group
@@ -177,6 +177,7 @@ def __calculate_equities_0(
177
177
  assert len(board_cards) == board_dealing_count
178
178
 
179
179
  equities = [0.0] * len(hole_cards)
180
+ qualification_count = 0
180
181
 
181
182
  for hand_type in hand_types:
182
183
  hands = list(
@@ -186,12 +187,18 @@ def __calculate_equities_0(
186
187
  ),
187
188
  )
188
189
  max_hand = max_or_none(hands)
189
- statuses = list(map(partial(eq, max_hand), hands))
190
- increment = 1 / (len(hand_types) * sum(statuses))
191
190
 
192
- for i, status in enumerate(statuses):
193
- if status:
194
- equities[i] += increment
191
+ if max_hand is not None:
192
+ qualification_count += 1
193
+ statuses = list(map(partial(eq, max_hand), hands))
194
+ increment = 1 / sum(statuses)
195
+
196
+ for i, status in enumerate(statuses):
197
+ if status:
198
+ equities[i] += increment
199
+
200
+ for i, equity in enumerate(equities):
201
+ equities[i] = equity / qualification_count
195
202
 
196
203
  return equities
197
204
 
@@ -1194,7 +1194,7 @@ class PotLimitOmahaHoldem(
1194
1194
 
1195
1195
 
1196
1196
  class FixedLimitOmahaHoldemHighLowSplitEightOrBetter(
1197
- PotLimitPokerMixin,
1197
+ FixedLimitPokerMixin,
1198
1198
  OmahaHoldemMixin,
1199
1199
  Holdem,
1200
1200
  ):
@@ -4771,6 +4771,27 @@ class State:
4771
4771
  assert self.street is not None
4772
4772
 
4773
4773
  if (
4774
+ self.checking_or_calling_amount is not None
4775
+ and (
4776
+ self.betting_structure == BettingStructure.POT_LIMIT
4777
+ or self.betting_structure == BettingStructure.NO_LIMIT
4778
+ )
4779
+ and (
4780
+ self.checking_or_calling_amount
4781
+ < self.completion_betting_or_raising_amount
4782
+ )
4783
+ ):
4784
+ raise ValueError('Short all-in cannot be raised.')
4785
+ elif (
4786
+ self.checking_or_calling_amount is not None
4787
+ and self.betting_structure == BettingStructure.FIXED_LIMIT
4788
+ and (
4789
+ 2 * self.checking_or_calling_amount
4790
+ < self.completion_betting_or_raising_amount
4791
+ )
4792
+ ):
4793
+ raise ValueError('Half-bet all-in cannot be raised.')
4794
+ elif (
4774
4795
  self.completion_betting_or_raising_count
4775
4796
  == self.street.max_completion_betting_or_raising_count
4776
4797
  ):
@@ -4784,6 +4805,10 @@ class State:
4784
4805
 
4785
4806
  if (
4786
4807
  self.consecutive_short_all_in_amounts
4808
+ and (
4809
+ self.betting_structure == BettingStructure.POT_LIMIT
4810
+ or self.betting_structure == BettingStructure.NO_LIMIT
4811
+ )
4787
4812
  and (
4788
4813
  sum(self.consecutive_short_all_in_amounts)
4789
4814
  < self.completion_betting_or_raising_amount
@@ -4796,8 +4821,22 @@ class State:
4796
4821
  ' of a non-full all-in wager'
4797
4822
  ),
4798
4823
  )
4799
-
4800
- if (
4824
+ elif (
4825
+ self.consecutive_short_all_in_amounts
4826
+ and self.betting_structure == BettingStructure.FIXED_LIMIT
4827
+ and (
4828
+ 2 * sum(self.consecutive_short_all_in_amounts)
4829
+ < self.completion_betting_or_raising_amount
4830
+ )
4831
+ and player_index in self.acted_player_indices
4832
+ ):
4833
+ raise ValueError(
4834
+ (
4835
+ 'The player already acted and hence cannot raise in face'
4836
+ ' of a non-half-bet all-in wager'
4837
+ ),
4838
+ )
4839
+ elif (
4801
4840
  self.stacks[player_index]
4802
4841
  <= max(self.bets) - self.bets[player_index]
4803
4842
  ):
@@ -6029,12 +6068,19 @@ class State:
6029
6068
  hand_type_indices = []
6030
6069
 
6031
6070
  for k in self.hand_type_indices:
6032
- for hand in self.get_up_hands(j, k):
6033
- if hand is not None:
6071
+ for player_index in pot.player_indices:
6072
+ if self.get_up_hand(
6073
+ player_index,
6074
+ j,
6075
+ k,
6076
+ ) is not None:
6034
6077
  hand_type_indices.append(k)
6035
6078
 
6036
6079
  break
6037
6080
 
6081
+ if not hand_type_indices:
6082
+ hand_type_indices = list(self.hand_type_indices)
6083
+
6038
6084
  hand_type_count = len(hand_type_indices)
6039
6085
  sub_quotient, sub_remainder = self.divmod(
6040
6086
  sub_amount,
@@ -6,7 +6,11 @@ from concurrent.futures import ProcessPoolExecutor
6
6
  from unittest import TestCase, main
7
7
 
8
8
  from pokerkit.analysis import calculate_equities, parse_range
9
- from pokerkit.hands import StandardHighHand
9
+ from pokerkit.hands import (
10
+ OmahaEightOrBetterLowHand,
11
+ OmahaHoldemHand,
12
+ StandardHighHand,
13
+ )
10
14
  from pokerkit.utilities import Card, Deck
11
15
 
12
16
 
@@ -491,6 +495,37 @@ class HandHistoryTestCase(TestCase):
491
495
  self.assertAlmostEqual(equities[0], 0.5)
492
496
  self.assertAlmostEqual(equities[1], 0.5)
493
497
 
498
+ def test_scoops(self) -> None:
499
+ board_cards = tuple(Card.parse('KhQdJc9s8h'))
500
+ hole_cards = tuple(
501
+ map(tuple, map(Card.parse, ('AcAd2s3s', 'KcKd4s5s'))),
502
+ )
503
+
504
+ for cards in hole_cards:
505
+ self.assertIsNone(
506
+ OmahaEightOrBetterLowHand.from_game_or_none(
507
+ cards,
508
+ board_cards,
509
+ ),
510
+ )
511
+
512
+ self.assertLess(
513
+ OmahaHoldemHand.from_game(hole_cards[0], board_cards),
514
+ OmahaHoldemHand.from_game(hole_cards[1], board_cards),
515
+ )
516
+
517
+ actual = calculate_equities(
518
+ ((cards,) for cards in hole_cards),
519
+ board_cards,
520
+ 4,
521
+ 5,
522
+ Deck.STANDARD,
523
+ (OmahaHoldemHand, OmahaEightOrBetterLowHand),
524
+ sample_count=1,
525
+ )
526
+
527
+ self.assertSequenceEqual(actual, [0, 1])
528
+
494
529
 
495
530
  if __name__ == '__main__':
496
531
  main() # pragma: no cover
@@ -13,6 +13,7 @@ from pokerkit.games import (
13
13
  FixedLimitOmahaHoldemHighLowSplitEightOrBetter,
14
14
  FixedLimitRazz,
15
15
  FixedLimitSevenCardStud,
16
+ FixedLimitTexasHoldem,
16
17
  LeducHoldem,
17
18
  NoLimitDeuceToSevenLowballSingleDraw,
18
19
  NoLimitShortDeckHoldem,
@@ -1840,6 +1841,81 @@ class StateTestCase(TestCase):
1840
1841
 
1841
1842
  self.assertEqual(state.deck, Deck.NUMERAL211_HOLDEM)
1842
1843
 
1844
+ def test_short_all_ins(self) -> None:
1845
+ state = NoLimitTexasHoldem.create_state(
1846
+ tuple(Automation),
1847
+ True,
1848
+ 0,
1849
+ (1, 2),
1850
+ 2,
1851
+ (1002, 152, 1002, 202),
1852
+ 4,
1853
+ )
1854
+
1855
+ state.check_or_call()
1856
+ state.check_or_call()
1857
+ state.check_or_call()
1858
+ state.check_or_call()
1859
+
1860
+ state.complete_bet_or_raise_to(100)
1861
+ state.complete_bet_or_raise_to(150)
1862
+ state.check_or_call()
1863
+ state.complete_bet_or_raise_to(200)
1864
+ self.assertTrue(state.can_complete_bet_or_raise_to(300))
1865
+ state.check_or_call()
1866
+ self.assertEqual(state.actor_index, 2)
1867
+ self.assertEqual(state.checking_or_calling_amount, 50)
1868
+ self.assertFalse(state.can_complete_bet_or_raise_to(300))
1869
+
1870
+ def test_half_bet_all_in(self) -> None:
1871
+ state = FixedLimitTexasHoldem.create_state(
1872
+ tuple(Automation),
1873
+ True,
1874
+ 0,
1875
+ (5, 10),
1876
+ 10,
1877
+ 20,
1878
+ (200, 25, 200, 200),
1879
+ 4,
1880
+ )
1881
+
1882
+ state.check_or_call()
1883
+ state.check_or_call()
1884
+ state.check_or_call()
1885
+ state.check_or_call()
1886
+
1887
+ state.complete_bet_or_raise_to(10)
1888
+ state.complete_bet_or_raise_to(15)
1889
+ state.check_or_call()
1890
+ state.check_or_call()
1891
+ self.assertEqual(state.actor_index, 0)
1892
+ self.assertEqual(state.checking_or_calling_amount, 5)
1893
+ self.assertTrue(state.can_complete_bet_or_raise_to())
1894
+
1895
+ state = FixedLimitTexasHoldem.create_state(
1896
+ tuple(Automation),
1897
+ True,
1898
+ 0,
1899
+ (5, 10),
1900
+ 10,
1901
+ 20,
1902
+ (200, 24, 200, 200),
1903
+ 4,
1904
+ )
1905
+
1906
+ state.check_or_call()
1907
+ state.check_or_call()
1908
+ state.check_or_call()
1909
+ state.check_or_call()
1910
+
1911
+ state.complete_bet_or_raise_to(10)
1912
+ state.complete_bet_or_raise_to(14)
1913
+ state.check_or_call()
1914
+ state.check_or_call()
1915
+ self.assertEqual(state.actor_index, 0)
1916
+ self.assertEqual(state.checking_or_calling_amount, 4)
1917
+ self.assertFalse(state.can_complete_bet_or_raise_to())
1918
+
1843
1919
 
1844
1920
  if __name__ == '__main__':
1845
1921
  main() # pragma: no cover
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pokerkit
3
- Version: 0.7.7.dev0
3
+ Version: 0.7.8
4
4
  Summary: An open-source Python library for poker game simulations, hand evaluations, and statistical analysis
5
5
  Home-page: https://github.com/uoftcprg/pokerkit
6
6
  Author: Universal, Open, Free, and Transparent Computer Poker Research Group
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
6
  name='pokerkit',
7
- version='0.7.7.dev0',
7
+ version='0.7.8',
8
8
  description=(
9
9
  'An open-source Python library for poker game simulations, hand'
10
10
  ' evaluations, and statistical analysis'
File without changes
File without changes
File without changes