haive.games.hold_em.state ========================= .. py:module:: haive.games.hold_em.state .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: haive.games.hold_em.state.GamePhase haive.games.hold_em.state.HoldemState haive.games.hold_em.state.PlayerAction haive.games.hold_em.state.PlayerDecision haive.games.hold_em.state.PlayerState haive.games.hold_em.state.PlayerStatus haive.games.hold_em.state.PokerAction Functions --------- .. autoapisummary:: haive.games.hold_em.state.last_value_reducer Module Contents --------------- .. py:class:: GamePhase Bases: :py:obj:`str`, :py:obj:`enum.Enum` Game phases in Texas Hold'em. Initialize self. See help(type(self)) for accurate signature. .. py:class:: HoldemState(/, **data) Bases: :py:obj:`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. .. py:class:: Config Pydantic configuration. .. py:method:: advance_to_next_player() Advance to the next player who can act. .. py:method:: get_player_by_id(player_id) Get player by ID. .. py:method:: get_player_by_index(index) Get player by index. .. py:method:: is_betting_complete() Check if betting round is complete. .. py:property:: active_players :type: list[PlayerState] Get list of active players. .. py:property:: current_player :type: PlayerState | None Get the current player to act. .. py:property:: players_in_hand :type: list[PlayerState] Get players still in the current hand (not folded). .. py:property:: players_to_act :type: list[PlayerState] Get players who still need to act this round. .. py:property:: total_pot :type: int Calculate total pot including side pots. .. py:class:: PlayerAction(/, **data) Bases: :py:obj:`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. .. py:class:: PlayerDecision(/, **data) Bases: :py:obj:`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. .. py:class:: PlayerState(/, **data) Bases: :py:obj:`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. .. py:class:: PlayerStatus Bases: :py:obj:`str`, :py:obj:`enum.Enum` Player status in the game. Initialize self. See help(type(self)) for accurate signature. .. py:class:: PokerAction Bases: :py:obj:`str`, :py:obj:`enum.Enum` Possible poker actions. Initialize self. See help(type(self)) for accurate signature. .. py:function:: last_value_reducer(a, b) Reducer that takes the last value - for fields that should be overwritten.