games.poker.models¶
Core data models for the Poker game implementation.
This module defines the fundamental data structures and models used in the poker game, including:
Card suits and values
Hand rankings and game phases
Player actions and states
Game state tracking
Decision models for LLM output
The models use Pydantic for validation and serialization, ensuring type safety and consistent data structures throughout the game.
Examples
>>> from poker.models import Card, Suit, CardValue
>>>
>>> # Create a card
>>> ace_of_spades = Card(suit=Suit.SPADES, value=CardValue.ACE)
>>> print(ace_of_spades) # Shows "Ace of spades"
Classes¶
Record of a player's action. |
|
Agent's decision in the game. |
|
Schema for LLM decision output. |
|
Playing card model. |
|
Card value enumeration. |
|
Poker game phase enumeration. |
|
Poker game result record. |
|
Playing hand model. |
|
Poker hand ranking enumeration. |
|
Poker hand ranking result. |
|
Player model for poker game. |
|
Player action enumeration. |
|
Player's view of the game state. |
|
Texas Hold'em poker game state. |
|
Poker pot model. |
|
Card suit enumeration. |
Module Contents¶
- class games.poker.models.ActionRecord(/, **data)¶
Bases:
pydantic.BaseModel
Record of a player’s action.
Tracks a single action taken by a player during the game, including the type of action, amount (if any), and game phase.
- Parameters:
data (Any)
- action¶
Type of action taken
- Type:
Examples
>>> record = ActionRecord( ... player_id="p1", ... action=PlayerAction.RAISE, ... amount=100, ... phase=GamePhase.FLOP ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.AgentDecision(/, **data)¶
Bases:
pydantic.BaseModel
Agent’s decision in the game.
Represents a decision made by an AI agent, including the action, bet amount (if any), and reasoning behind the decision.
- Parameters:
data (Any)
- action¶
Chosen action
- Type:
Examples
>>> decision = AgentDecision( ... action=PlayerAction.RAISE, ... amount=100, ... reasoning="Strong hand, building pot" ... ) >>> print(decision) # Shows decision details
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.AgentDecisionSchema(/, **data)¶
Bases:
pydantic.BaseModel
Schema for LLM decision output.
Defines the expected structure for decisions generated by the language model, ensuring consistent and valid output format.
- Parameters:
data (Any)
- action¶
Type of action to take
- Type:
Examples
>>> schema = AgentDecisionSchema( ... action=PlayerAction.CALL, ... amount=50, ... reasoning="Good pot odds with drawing hand" ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.Card(/, **data)¶
Bases:
pydantic.BaseModel
Playing card model.
Represents a standard playing card with suit and value. Provides methods for numeric value comparison.
- Parameters:
data (Any)
Examples
>>> card = Card(suit=Suit.HEARTS, value=CardValue.ACE) >>> print(card) # Shows "Ace of hearts" >>> print(card.numeric_value) # Shows 14
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.CardValue¶
-
Card value enumeration.
Represents standard playing card values from 2 to Ace. Inherits from int.Enum for numeric comparison (e.g., King > Queen). Ace is highest by default (14) but can be treated as 1 in certain contexts (e.g., A-2-3-4-5 straight).
- ...
Initialize self. See help(type(self)) for accurate signature.
- class games.poker.models.GamePhase¶
-
Poker game phase enumeration.
Represents the different phases of a Texas Hold’em poker game. Inherits from str.Enum for easy serialization and comparison.
Initialize self. See help(type(self)) for accurate signature.
- class games.poker.models.GameResult(/, **data)¶
Bases:
pydantic.BaseModel
Poker game result record.
Stores the final outcome of a completed game, including winners, chip counts, and hand rankings.
- Parameters:
data (Any)
- hand_rankings¶
Final hand evaluations
- Type:
Dict[str, HandRanking]
Examples
>>> result = GameResult( ... winners=["p1"], ... final_chips={"p1": 2000, "p2": 0}, ... hand_rankings={"p1": ace_high_flush}, ... total_hands_played=1 ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.Hand(/, **data)¶
Bases:
pydantic.BaseModel
Playing hand model.
Represents a collection of cards held by a player or on the board. Limited to 7 cards maximum (2 hole cards + 5 community cards).
- Parameters:
data (Any)
Examples
>>> hand = Hand(cards=[ ... Card(suit=Suit.HEARTS, value=CardValue.ACE), ... Card(suit=Suit.HEARTS, value=CardValue.KING) ... ]) >>> print(hand) # Shows "Ace of hearts, King of hearts"
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.HandRank¶
-
Poker hand ranking enumeration.
Represents the standard poker hand rankings from high card to royal flush. Inherits from int.Enum for easy comparison of hand strengths.
Initialize self. See help(type(self)) for accurate signature.
- class games.poker.models.HandRanking(/, **data)¶
Bases:
pydantic.BaseModel
Poker hand ranking result.
Represents the evaluation of a player’s best possible hand, including rank, high cards for tiebreakers, and description.
- Parameters:
data (Any)
Examples
>>> ranking = HandRanking( ... player_id="p1", ... rank=HandRank.FLUSH, ... high_cards=[CardValue.ACE, CardValue.KING], ... description="Ace-high flush" ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.Player(/, **data)¶
Bases:
pydantic.BaseModel
Player model for poker game.
Represents a player in the game, tracking their cards, chips, and game status. Includes betting information and position at the table.
- Parameters:
data (Any)
Examples
>>> player = Player( ... id="p1", ... name="Alice", ... chips=1000, ... position=0 ... ) >>> print(player) # Shows "Player Alice ($1000)"
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.PlayerAction¶
-
Player action enumeration.
Represents the possible actions a player can take during their turn. Inherits from str.Enum for easy serialization and comparison.
Initialize self. See help(type(self)) for accurate signature.
- class games.poker.models.PlayerObservation(/, **data)¶
Bases:
pydantic.BaseModel
Player’s view of the game state.
Represents what a specific player can observe about the current game state, hiding information they shouldn’t have access to (e.g., other players’ hole cards).
- Parameters:
data (Any)
- recent_actions¶
Recent action history
- Type:
List[ActionRecord]
Examples
>>> obs = PlayerObservation( ... player_id="p1", ... hand=Hand(cards=[ace_of_spades, king_of_hearts]), ... position=0, ... position_name="Button" ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.PokerGameState(/, **data)¶
Bases:
pydantic.BaseModel
Texas Hold’em poker game state.
Comprehensive model of the current game state, including all player information, community cards, betting status, and game progression.
- Parameters:
data (Any)
- action_history¶
Record of all actions
- Type:
List[ActionRecord]
- hand_rankings¶
Final hand evaluations
- Type:
Dict[str, HandRanking]
Examples
>>> state = PokerGameState( ... players=[Player(id="p1", name="Alice")], ... small_blind=5, ... big_blind=10 ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.Pot(/, **data)¶
Bases:
pydantic.BaseModel
Poker pot model.
Represents a pot of chips in the game, tracking both the amount and which players are eligible to win it (for side pots).
- Parameters:
data (Any)
Examples
>>> pot = Pot( ... amount=500, ... eligible_players=["p1", "p2", "p3"] ... )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class games.poker.models.Suit¶
-
Card suit enumeration.
Represents the four standard playing card suits. Inherits from str.Enum for easy serialization and string comparison.
Initialize self. See help(type(self)) for accurate signature.