Skip to content

Commit

Permalink
Change Game constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
AussieSeaweed committed Dec 4, 2023
1 parent ed716f4 commit 4538efc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 55 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Changelog

All notable changes to this project will be documented in this file.

Version 0.3.2 (December 4, 2023)
-------------------------------

**Changed**

- When saving state configuration, ``player_count`` is not saved.

Version 0.3.1 (December 4, 2023)
-------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project = 'PokerKit'
copyright = '2023, University of Toronto Computer Poker Research Group'
author = 'University of Toronto Computer Poker Research Group'
release = '0.3.1'
release = '0.3.2'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
77 changes: 24 additions & 53 deletions pokerkit/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
StandardLowHand,
)
from pokerkit.state import BettingStructure, Opening, Automation, State, Street
from pokerkit.utilities import clean_values, Deck, RankOrder, ValuesLike
from pokerkit.utilities import Deck, RankOrder, ValuesLike


class Poker(ABC):
Expand All @@ -29,7 +29,6 @@ class Poker(ABC):
:param raw_antes: The raw antes.
:param raw_blinds_or_straddles: The raw blinds or straddles.
:param bring_in: The bring-in.
:param player_count: The number of players.
"""

deck: ClassVar[Deck]
Expand All @@ -47,7 +46,6 @@ def __init__(
raw_antes: ValuesLike,
raw_blinds_or_straddles: ValuesLike,
bring_in: int,
player_count: int,
) -> None:
self.automations: tuple[Automation, ...] = automations
"""The automations."""
Expand All @@ -60,31 +58,30 @@ def __init__(
If you want non-uniform antes like big blind antes, set
this to ``False``.
"""
self.antes: tuple[int, ...] = clean_values(raw_antes, player_count)
"""The antes."""
self.blinds_or_straddles: tuple[int, ...] = clean_values(
raw_blinds_or_straddles,
player_count,
)
"""The blinds or straddles."""
self.raw_antes: ValuesLike = raw_antes
"""The raw antes."""
self.raw_blinds_or_straddles: ValuesLike = raw_blinds_or_straddles
"""The raw blinds or straddles."""
self.bring_in: int = bring_in
"""The bring-in."""
self.player_count: int = player_count
"""The number of players."""

def __call__(self, raw_starting_stacks: ValuesLike) -> State:
def __call__(
self,
raw_starting_stacks: ValuesLike,
player_count: int,
) -> State:
return State(
self.automations,
self.deck,
self.hand_types,
self.streets,
self.betting_structure,
self.ante_trimming_status,
self.antes,
self.blinds_or_straddles,
self.raw_antes,
self.raw_blinds_or_straddles,
self.bring_in,
raw_starting_stacks,
self.player_count,
player_count,
)

@property
Expand Down Expand Up @@ -180,7 +177,6 @@ class Holdem(Poker, ABC):
:param raw_blinds_or_straddles: The raw blinds or straddles.
:param small_bet: The small bet.
:param big_bet: The big bet.
:param player_count: The number of players.
"""

hole_dealing_count: ClassVar[int]
Expand All @@ -196,7 +192,6 @@ def __init__(
raw_blinds_or_straddles: ValuesLike,
small_bet: int,
big_bet: int,
player_count: int,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -242,7 +237,6 @@ def __init__(
raw_antes,
raw_blinds_or_straddles,
0,
player_count,
)


Expand All @@ -254,7 +248,6 @@ class UnfixedLimitHoldem(Holdem, ABC):
:param raw_antes: The raw antes.
:param raw_blinds_or_straddles: The raw blinds or straddles.
:param min_bet: The minimum bet.
:param player_count: The number of players.
"""

max_completion_betting_or_raising_count: ClassVar[int | None] = None
Expand All @@ -266,7 +259,6 @@ def __init__(
raw_antes: ValuesLike,
raw_blinds_or_straddles: ValuesLike,
min_bet: int,
player_count: int,
) -> None:
super().__init__(
automations,
Expand All @@ -275,7 +267,6 @@ def __init__(
raw_blinds_or_straddles,
min_bet,
min_bet,
player_count,
)


Expand Down Expand Up @@ -362,8 +353,7 @@ def create_state(
raw_blinds_or_straddles,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class NoLimitTexasHoldem(
Expand Down Expand Up @@ -477,8 +467,7 @@ def create_state(
raw_antes,
raw_blinds_or_straddles,
min_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class NoLimitShortDeckHoldem(NoLimitPokerMixin, UnfixedLimitHoldem):
Expand Down Expand Up @@ -593,8 +582,7 @@ def create_state(
raw_antes,
raw_blinds_or_straddles,
min_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class OmahaHoldemMixin:
Expand Down Expand Up @@ -712,8 +700,7 @@ def create_state(
raw_antes,
raw_blinds_or_straddles,
min_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class FixedLimitOmahaHoldemHighLowSplitEightOrBetter(
Expand Down Expand Up @@ -762,8 +749,7 @@ def create_state(
raw_blinds_or_straddles,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class SevenCardStud(Poker, ABC):
Expand All @@ -775,7 +761,6 @@ class SevenCardStud(Poker, ABC):
:param bring_in: The bring-in.
:param small_bet: The small bet.
:param big_bet: The big bet.
:param player_count: The number of players.
"""

max_completion_betting_or_raising_count: ClassVar[int | None]
Expand All @@ -791,7 +776,6 @@ def __init__(
bring_in: int,
small_bet: int,
big_bet: int,
player_count: int,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -846,7 +830,6 @@ def __init__(
raw_antes,
None,
bring_in,
player_count,
)


Expand Down Expand Up @@ -888,8 +871,7 @@ def create_state(
bring_in,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class FixedLimitSevenCardStudHighLowSplitEightOrBetter(
Expand Down Expand Up @@ -939,8 +921,7 @@ def create_state(
bring_in,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class FixedLimitRazz(FixedLimitPokerMixin, SevenCardStud):
Expand Down Expand Up @@ -981,8 +962,7 @@ def create_state(
bring_in,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class Draw(Poker, ABC):
Expand All @@ -1002,7 +982,6 @@ class SingleDraw(Draw, ABC):
:param raw_antes: The raw antes.
:param raw_blinds_or_straddles: The raw blinds or straddles.
:param min_bet: The min bet.
:param player_count: The number of players.
"""

def __init__(
Expand All @@ -1012,7 +991,6 @@ def __init__(
raw_antes: ValuesLike,
raw_blinds_or_straddles: ValuesLike,
min_bet: int,
player_count: int,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -1040,7 +1018,6 @@ def __init__(
raw_antes,
raw_blinds_or_straddles,
0,
player_count,
)


Expand All @@ -1053,7 +1030,6 @@ class TripleDraw(Draw, ABC):
:param raw_blinds_or_straddles: The raw blinds or straddles.
:param small_bet: The small bet.
:param big_bet: The big bet.
:param player_count: The number of players.
"""

def __init__(
Expand All @@ -1064,7 +1040,6 @@ def __init__(
raw_blinds_or_straddles: ValuesLike,
small_bet: int,
big_bet: int,
player_count: int,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -1110,7 +1085,6 @@ def __init__(
raw_antes,
raw_blinds_or_straddles,
0,
player_count,
)


Expand Down Expand Up @@ -1158,8 +1132,7 @@ def create_state(
raw_antes,
raw_blinds_or_straddles,
min_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class FixedLimitDeuceToSevenLowballTripleDraw(
Expand Down Expand Up @@ -1295,8 +1268,7 @@ def create_state(
raw_blinds_or_straddles,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)


class FixedLimitBadugi(FixedLimitPokerMixin, TripleDraw):
Expand Down Expand Up @@ -1450,5 +1422,4 @@ def create_state(
raw_blinds_or_straddles,
small_bet,
big_bet,
player_count,
)(raw_starting_stacks)
)(raw_starting_stacks, player_count)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='pokerkit',
version='0.3.1',
version='0.3.2',
description='An open-source Python library for poker simulations and hand evaluations',
long_description=open('README.rst').read(),
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit 4538efc

Please sign in to comment.