Skip to content

Commit

Permalink
Add new rake features
Browse files Browse the repository at this point in the history
  • Loading branch information
AussieSeaweed committed Apr 24, 2024
1 parent 9f30fdb commit c1708d6
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 73 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ This version release introduces a number of backward incompatible changes. Pleas

- The card-burning-related methods ``pokerkit.state.State.verify_card_burning``, ``pokerkit.state.State.can_burn_card``, and ``pokerkit.state.State.burn_card`` also accept a singleton card iterable.
- The ``pokerkit.state.State.all_in_show_status`` was renamed to ``pokerkit.state.State.all_in_status``.
- Renamed ``pokerkit.state.ChipsPushing.rake`` to ``pokerkit.state.ChipsPushing.raked_amount``.
- The attribute ``pokerkit.state.Pot.amount`` is now a property and no longer a parameter during initialization.

**Added**

Expand Down Expand Up @@ -68,6 +70,9 @@ This version release introduces a number of backward incompatible changes. Pleas

- New attribute ``pokerkit.state.State.runout_count_selector_statuses`` that keeps track of who can select the number of runouts.
- New attribute ``pokerkit.state.State.runout_count_selection_flag`` that keeps track of whether the runout count selection has been carried out.
- In ``pokerkit.utilities.rake``, added parameters ``state``, ``cap``, and ``no_flop_no_drop``, and ``rake`` is now renamed as ``percentage`` and is a keyword parameter.
- New attributes ``pokerkit.state.Pot.raked_amount`` and ``pokerkit.state.Pot.unraked_amount`` that gives the raked and the unraked amounts of the pot.
- New property ``pokerkit.state.ChipsPushing.unraked_amount``.

Version 0.4.17 (April 9, 2024)
------------------------------
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 Student Research Group'
author = 'University of Toronto Computer Poker Student Research Group'
release = '0.5.0a0'
release = '0.5.0a1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ The programmer can also define a custom function that divides up the pot to tail
Optional: Rake
^^^^^^^^^^^^^^

This is an optional parameter. It is a callable that takes a rake from the pot(s). By default, PokerKit states take no rake. The default :func:`pokerkit.utilities.rake` function can accept parameters to take a non-zero rake. You can use ``functools.partial`` with it and supply it as the rake function. Of course, the user can define their own to do something more complex like min-rake or max-rake per pot.
This is an optional parameter. It is a callable that takes a rake from the pot(s). By default, PokerKit states take no rake. The default :func:`pokerkit.utilities.rake` function can accept parameters to take a non-zero rake, have a rake-cap, or facilitate the no-flop-no-drop rule. You can use ``functools.partial`` with it and supply it as the rake function. Of course, the user can define their own to do something more complex like min-rake or max-rake per pot depending on the poker state.

Methods and Attributes
^^^^^^^^^^^^^^^^^^^^^^
Expand Down
37 changes: 18 additions & 19 deletions pokerkit/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from abc import ABC
from collections.abc import Callable
from functools import partial
from typing import ClassVar

from pokerkit.hands import (
Expand Down Expand Up @@ -89,7 +88,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
self.automations: tuple[Automation, ...] = automations
"""The automations.
Expand Down Expand Up @@ -160,7 +159,7 @@ def __init__(
This is used to denote how pots are divided up (for multiple
boards, multiple winners, multiple hand types, etc.).
"""
self.rake: Callable[[int], tuple[int, int]] = rake
self.rake: Callable[[int, State], tuple[int, int]] = rake
"""The rake function.
Rake functions are used in PokerKit to denote how the rakes are
Expand Down Expand Up @@ -423,7 +422,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -503,7 +502,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -545,7 +544,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit Texas hold'em game.
Expand Down Expand Up @@ -639,7 +638,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a no-limit Texas hold'em game.
Expand Down Expand Up @@ -918,7 +917,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a no-limit short-deck hold'em game.
Expand Down Expand Up @@ -1062,7 +1061,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a pot-limit Omaha hold'em game.
Expand Down Expand Up @@ -1207,7 +1206,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit Omaha hold'em high/low-split eight or better
low game.
Expand Down Expand Up @@ -1272,7 +1271,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -1356,7 +1355,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit seven card stud game.
Expand Down Expand Up @@ -1418,7 +1417,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit seven card stud high/low-split eight or
better low game.
Expand Down Expand Up @@ -1473,7 +1472,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit razz game.
Expand Down Expand Up @@ -1539,7 +1538,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -1601,7 +1600,7 @@ def __init__(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> None:
super().__init__(
automations,
Expand Down Expand Up @@ -1684,7 +1683,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a no-limit deuce-to-seven lowball single draw game.
Expand Down Expand Up @@ -1738,7 +1737,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit deuce-to-seven lowball triple draw game.
Expand Down Expand Up @@ -1890,7 +1889,7 @@ def create_state(
mode: Mode = Mode.TOURNAMENT,
starting_board_count: int = 1,
divmod: Callable[[int, int], tuple[int, int]] = divmod,
rake: Callable[[int], tuple[int, int]] = partial(rake, rake=0),
rake: Callable[[int, State], tuple[int, int]] = rake,
) -> State:
"""Create a fixed-limit badugi game.
Expand Down
Loading

0 comments on commit c1708d6

Please sign in to comment.