games.poker.agent¶

Enhanced Texas Hold’em Poker agent implementation.

This module implements a robust poker agent with improved: - Structured output handling with proper schema validation - Comprehensive logging and debugging - Error handling and retry policies for invalid moves - Enhanced prompts for LLM decisions

Classes¶

PokerAgent

Enhanced agent class for managing a multi-player Texas Hold'em poker game.

RetryConfiguration

Configuration for retry policies.

Module Contents¶

class games.poker.agent.PokerAgent(config=PokerAgentConfig())¶

Bases: haive.core.engine.agent.agent.Agent[haive.games.poker.config.PokerAgentConfig]

Enhanced agent class for managing a multi-player Texas Hold’em poker game.

Key improvements: - Proper structured output handling - Comprehensive debug logging - Retry policies for failed operations - Enhanced prompts and decision handling

Initialize the enhanced poker agent.

Parameters:

config (haive.games.poker.config.PokerAgentConfig)

end_game(state)¶

End the poker game and determine final results.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

end_hand(state)¶

Handle the end of a hand - determine winner(s) and update stats.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

handle_player_decision(state)¶

Enhanced player decision handling with improved error recovery.

This method: 1. Determines the current player 2. Calculates legal actions 3. Gets decision from the player agent 4. Validates and applies the decision 5. Updates game state

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

initialize_game(state)¶

Initialize the poker game state with enhanced logging.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

setup_hand(state)¶

Set up a new poker hand with enhanced error handling and debugging.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

setup_workflow()¶

Set up the poker game workflow graph with enhanced error handling.

should_continue_round(state)¶

Determine if we should continue the current betting round.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

str

should_continue_to_next_phase(state)¶

Determine if the game should advance to the next phase.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

str

should_play_another_hand(state)¶

Determine if another hand should be played.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

bool

update_game_phase(state)¶

Update the game phase and handle phase transitions.

Parameters:

state (haive.games.poker.state.PokerState)

Return type:

haive.games.poker.state.PokerState

class games.poker.agent.RetryConfiguration¶

Configuration for retry policies.