clubs.render package¶
Submodules¶
clubs.render.ascii_viewer module¶
-
class
clubs.render.ascii_viewer.
ASCIIViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, **kwargs)[source]¶ Bases:
clubs.render.viewer.PokerViewer
Poker game renderer which prints an ascii representation of the table state to the terminal
- Parameters
num_players (int) – number of players
num_hole_cards (int) – number of hole cards
num_community_cards (int) – number of community cards
-
KEYS
= ['p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p0c', 'p1c', 'p2c', 'p3c', 'p4c', 'p5c', 'p6c', 'p7c', 'p8c', 'p9c', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'sb', 'bb', 'ccs', 'pot', 'action']¶
-
POS_DICT
= {2: [0, 5], 3: [0, 3, 6], 4: [0, 2, 4, 6], 5: [0, 2, 4, 6, 8], 6: [0, 1, 3, 5, 6, 8], 7: [0, 1, 3, 5, 6, 7, 9], 8: [0, 1, 2, 4, 5, 6, 7, 9], 9: [0, 1, 2, 4, 5, 6, 7, 8, 9], 10: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}¶
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render ascii table representation based on the table configuration
- Parameters
config (Dict[str, Any]) –
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }
clubs.render.graphic module¶
-
class
clubs.render.graphic.
GraphicViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, host: str = '127.0.0.1', port: int = 0, **kwargs)[source]¶ Bases:
clubs.render.viewer.PokerViewer
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render the table in browser based on the table configuration
- Parameters
config (Dict[str, Any]) – game configuration dictionary
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }
-
clubs.render.viewer module¶
-
class
clubs.render.viewer.
PokerViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, **kwargs)[source]¶ Bases:
object
Base class for renderer. Any renderer must subclass this renderer and implement the function render
- Parameters
num_players (int) – number of player
num_hole_cards (int) – number of hole cards
num_community_cards (int) – number of community cards
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render the table based on the table configuration
- Parameters
config (Dict[str, Any]) – game configuration dictionary
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }
Module contents¶
-
class
clubs.render.
ASCIIViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, **kwargs)[source]¶ Bases:
clubs.render.viewer.PokerViewer
Poker game renderer which prints an ascii representation of the table state to the terminal
- Parameters
num_players (int) – number of players
num_hole_cards (int) – number of hole cards
num_community_cards (int) – number of community cards
-
KEYS
= ['p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p0c', 'p1c', 'p2c', 'p3c', 'p4c', 'p5c', 'p6c', 'p7c', 'p8c', 'p9c', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'sb', 'bb', 'ccs', 'pot', 'action']¶
-
POS_DICT
= {2: [0, 5], 3: [0, 3, 6], 4: [0, 2, 4, 6], 5: [0, 2, 4, 6, 8], 6: [0, 1, 3, 5, 6, 8], 7: [0, 1, 3, 5, 6, 7, 9], 8: [0, 1, 2, 4, 5, 6, 7, 9], 9: [0, 1, 2, 4, 5, 6, 7, 8, 9], 10: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}¶
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render ascii table representation based on the table configuration
- Parameters
config (Dict[str, Any]) –
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }
-
class
clubs.render.
GraphicViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, host: str = '127.0.0.1', port: int = 0, **kwargs)[source]¶ Bases:
clubs.render.viewer.PokerViewer
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render the table in browser based on the table configuration
- Parameters
config (Dict[str, Any]) – game configuration dictionary
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }
-
-
class
clubs.render.
PokerViewer
(num_players: int, num_hole_cards: int, num_community_cards: int, **kwargs)[source]¶ Bases:
object
Base class for renderer. Any renderer must subclass this renderer and implement the function render
- Parameters
num_players (int) – number of player
num_hole_cards (int) – number of hole cards
num_community_cards (int) – number of community cards
-
render
(config: Dict[str, Any], sleep: float = 0) → None[source]¶ Render the table based on the table configuration
- Parameters
config (Dict[str, Any]) – game configuration dictionary
sleep (float, optional) – sleep time after render, by default 0
Examples
>>> from clubs import Card >>> config = { ... 'action': 0, # int - position of active player ... 'active': [True, True], # List[bool] - list of active players ... 'all_in': [False, False], # List[bool] - list of all in players ... 'community_cards': [], # List[Card] - list of community cards ... 'dealer': 0, # int - position of dealer ... 'done': False, # bool - toggle if hand is completed ... 'hole_cards': [[Card("Ah")], [Card("Ac")]], # List[List[Card]] - ... # list of list of hole card ... 'pot': 10, # int - chips in pot ... 'payouts': [0, 0], # List[int] - list of chips won for each player ... 'prev_action': [1, 10, 0], # Tuple[int, int, int] - ... # last position bet and fold ... 'street_commits': [10, 20] # List[int] - list of number of ... # chips added to pot from each ... # player on current street ... 'stacks': [100, 100] # List[int] - list of stack sizes ... }