games.tic_tac_toe.generic_engines¶
Generic Tic Tac Toe engines using the new generic player agent system.
This module demonstrates how to use the generic player agent system for Tic Tac Toe, showing the same pattern working across different games with different player identifiers.
Classes¶
Tic Tac Toe-specific prompt generator using the generic system. |
Functions¶
Compare the chess vs tic-tac-toe patterns to show generalization. |
|
|
Create Tic Tac Toe engines from predefined examples using generics. |
|
Create Tic Tac Toe engines using the generic system. |
|
Create Tic Tac Toe engines with simple model configurations using generics. |
Create engines for multiple games to show the pattern. |
Module Contents¶
- class games.tic_tac_toe.generic_engines.TicTacToePromptGenerator(players)¶
Bases:
haive.games.core.agent.generic_player_agent.GenericPromptGenerator
[str
,str
]Tic Tac Toe-specific prompt generator using the generic system.
Init .
- Parameters:
players (GamePlayerIdentifiers[PlayerType, PlayerType2]) – [TODO: Add description]
- create_analysis_prompt(player)¶
Create a Tic Tac Toe analysis prompt for the specified player.
- Parameters:
player (str) – Player symbol (“X” or “O”)
- Returns:
Prompt template for position analysis
- Return type:
ChatPromptTemplate
- create_move_prompt(player)¶
Create a Tic Tac Toe move prompt for the specified player.
- Parameters:
player (str) – Player symbol (“X” or “O”)
- Returns:
Prompt template for move generation
- Return type:
ChatPromptTemplate
- get_analysis_output_model()¶
Get the structured output model for Tic Tac Toe analysis.
- Return type:
- games.tic_tac_toe.generic_engines.compare_chess_vs_ttt_patterns()¶
Compare the chess vs tic-tac-toe patterns to show generalization.
This function demonstrates how the same generic system works for different games with different player naming conventions.
- games.tic_tac_toe.generic_engines.create_generic_ttt_config_from_example(example_name, temperature=0.3)¶
Create Tic Tac Toe engines from predefined examples using generics.
- Parameters:
- Returns:
Dictionary of engines
- Return type:
- Available examples:
“gpt_vs_claude”: GPT-4 vs Claude
“gpt_only”: GPT-4 for both players
“claude_only”: Claude for both players
“budget”: Cost-effective models
“mixed”: Different provider per role
- games.tic_tac_toe.generic_engines.create_generic_ttt_engines(player_configs)¶
Create Tic Tac Toe engines using the generic system.
- Parameters:
player_configs (dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]) – Dictionary of role name to player configuration
- Returns:
Dictionary of configured engines
- Return type:
Example
>>> configs = { ... "X_player": PlayerAgentConfig(llm_config="gpt-4"), ... "O_player": PlayerAgentConfig(llm_config="claude-3-opus"), ... "X_analyzer": PlayerAgentConfig(llm_config="gpt-4"), ... "O_analyzer": PlayerAgentConfig(llm_config="claude-3-opus"), ... } >>> engines = create_generic_ttt_engines(configs)
- games.tic_tac_toe.generic_engines.create_generic_ttt_engines_simple(x_model='gpt-4o', o_model='claude-3-5-sonnet-20240620', temperature=0.3, **kwargs)¶
Create Tic Tac Toe engines with simple model configurations using generics.
- Parameters:
- Returns:
Dictionary of engines
- Return type:
Example
>>> engines = create_generic_ttt_engines_simple("gpt-4", "claude-3-opus") >>> engines = create_generic_ttt_engines_simple( ... "openai:gpt-4o", ... "anthropic:claude-3-5-sonnet-20240620", ... temperature=0.5 ... )
- games.tic_tac_toe.generic_engines.create_multi_game_comparison()¶
Create engines for multiple games to show the pattern.
This demonstrates how the same configuration approach works across different games with the generic system.