games.hold_em.state¶
Fixed Texas Hold’em game state models.
Key fixes: 1. Added Annotated type for current_player_index to handle concurrent updates 2. Fixed reducer setup for fields that might be updated concurrently 3. Added proper field annotations for LangGraph compatibility
Classes¶
Game phases in Texas Hold'em. |
|
State for the Texas Hold'em game. |
|
Represents a player action. |
|
Model for player decision-making. |
|
State for an individual player. |
|
Player status in the game. |
|
Possible poker actions. |
Functions¶
|
Reducer that takes the last value - for fields that should be overwritten. |
Module Contents¶
- class games.hold_em.state.GamePhase¶
-
Game phases in Texas Hold’em.
Initialize self. See help(type(self)) for accurate signature.
- class games.hold_em.state.HoldemState(/, **data)¶
Bases:
pydantic.BaseModel
State for the Texas Hold’em game.
- This class represents the complete game state including:
Players and their states
Community cards
Betting rounds
Pot information
Game phase tracking
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.
- Parameters:
data (Any)
- class Config¶
Pydantic configuration.
- get_player_by_id(player_id)¶
Get player by ID.
- Parameters:
player_id (str)
- Return type:
PlayerState | None
- get_player_by_index(index)¶
Get player by index.
- Parameters:
index (int)
- Return type:
PlayerState | None
- property active_players: list[PlayerState]¶
Get list of active players.
- Return type:
- property current_player: PlayerState | None¶
Get the current player to act.
- Return type:
PlayerState | None
- property players_in_hand: list[PlayerState]¶
Get players still in the current hand (not folded).
- Return type:
- property players_to_act: list[PlayerState]¶
Get players who still need to act this round.
- Return type:
- class games.hold_em.state.PlayerAction(/, **data)¶
Bases:
pydantic.BaseModel
Represents a player action.
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.
- Parameters:
data (Any)
- class games.hold_em.state.PlayerDecision(/, **data)¶
Bases:
pydantic.BaseModel
Model for player decision-making.
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.
- Parameters:
data (Any)
- class games.hold_em.state.PlayerState(/, **data)¶
Bases:
pydantic.BaseModel
State for an individual player.
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.
- Parameters:
data (Any)
- class games.hold_em.state.PlayerStatus¶
-
Player status in the game.
Initialize self. See help(type(self)) for accurate signature.
- class games.hold_em.state.PokerAction¶
-
Possible poker actions.
Initialize self. See help(type(self)) for accurate signature.
- games.hold_em.state.last_value_reducer(a, b)¶
Reducer that takes the last value - for fields that should be overwritten.
- Parameters:
a (Any)
b (Any)
- Return type:
Any