haive.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¶

GamePhase

Game phases in Texas Hold'em.

HoldemState

State for the Texas Hold'em game.

PlayerAction

Represents a player action.

PlayerDecision

Model for player decision-making.

PlayerState

State for an individual player.

PlayerStatus

Player status in the game.

PokerAction

Possible poker actions.

Functions¶

last_value_reducer(a, b)

Reducer that takes the last value - for fields that should be overwritten.

Module Contents¶

class haive.games.hold_em.state.GamePhase[source]¶

Bases: str, enum.Enum

Game phases in Texas Hold’em.

Initialize self. See help(type(self)) for accurate signature.

class haive.games.hold_em.state.HoldemState(/, **data)[source]¶

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[source]¶

Pydantic configuration.

advance_to_next_player()[source]¶

Advance to the next player who can act.

Return type:

int | None

get_player_by_id(player_id)[source]¶

Get player by ID.

Parameters:

player_id (str)

Return type:

PlayerState | None

get_player_by_index(index)[source]¶

Get player by index.

Parameters:

index (int)

Return type:

PlayerState | None

is_betting_complete()[source]¶

Check if betting round is complete.

Return type:

bool

property active_players: list[PlayerState]¶

Get list of active players.

Return type:

list[PlayerState]

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:

list[PlayerState]

property players_to_act: list[PlayerState]¶

Get players who still need to act this round.

Return type:

list[PlayerState]

property total_pot: int¶

Calculate total pot including side pots.

Return type:

int

class haive.games.hold_em.state.PlayerAction(/, **data)[source]¶

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 haive.games.hold_em.state.PlayerDecision(/, **data)[source]¶

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 haive.games.hold_em.state.PlayerState(/, **data)[source]¶

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 haive.games.hold_em.state.PlayerStatus[source]¶

Bases: str, enum.Enum

Player status in the game.

Initialize self. See help(type(self)) for accurate signature.

class haive.games.hold_em.state.PokerAction[source]¶

Bases: str, enum.Enum

Possible poker actions.

Initialize self. See help(type(self)) for accurate signature.

haive.games.hold_em.state.last_value_reducer(a, b)[source]¶

Reducer that takes the last value - for fields that should be overwritten.

Parameters:
  • a (Any)

  • b (Any)

Return type:

Any