games.mancala.agent_original¶
Mancala game agent.
This module defines the Mancala game agent, which uses language models to generate moves and analyze positions in the game.
Classes¶
Agent for playing Mancala. |
Functions¶
|
Ensure input is converted to MancalaState. |
Module Contents¶
- class games.mancala.agent_original.MancalaAgent(config=MancalaConfig())¶
Bases:
haive.games.framework.base.agent.GameAgent
[haive.games.mancala.config.MancalaConfig
]Agent for playing Mancala.
This class implements the Mancala game agent, which uses language models to generate moves and analyze positions in the game.
Initialize the Mancala agent.
- Parameters:
config (MancalaConfig) – The configuration for the Mancala game.
- analyze_player1(state)¶
Analyze position for player1.
- Parameters:
state (MancalaState) – Current game state.
- Returns:
Updated game state after the analysis.
- Return type:
Command
- analyze_player2(state)¶
Analyze position for player2.
- Parameters:
state (MancalaState) – Current game state.
- Returns:
Updated game state after the analysis.
- Return type:
Command
- analyze_position(state, player)¶
Analyze the current position for the specified player.
- Parameters:
state (MancalaState) – Current game state.
player (str) – The player making the analysis (‘player1’ or ‘player2’).
- Returns:
Updated game state after the analysis.
- Return type:
Command
- extract_analysis(response)¶
Extract analysis from engine response.
- Parameters:
response (Any) – Response from the engine.
- Returns:
Parsed analysis object.
- Return type:
Any
- extract_move(response)¶
Extract move from engine response.
- Parameters:
response (Any) – Response from the engine.
- Returns:
Parsed move object.
- Return type:
- initialize_game(state)¶
Initialize a new Mancala game with configured stones per pit.
- Parameters:
state (Dict[str, Any]) – Initial state dictionary (unused here but required for interface).
- Returns:
Initialization command containing the new game state fields.
- Return type:
Command
- make_move(state, player)¶
Make a move for the specified player.
- Parameters:
state (MancalaState) – Current game state.
player (str) – The player making the move (‘player1’ or ‘player2’).
- Returns:
Updated game state after the move.
- Return type:
Command
- make_player1_move(state)¶
Make a move for player1.
- Parameters:
state (MancalaState) – Current game state.
- Returns:
Updated game state after the move.
- Return type:
Command
- make_player2_move(state)¶
Make a move for player2.
- Parameters:
state (MancalaState) – Current game state.
- Returns:
Updated game state after the move.
- Return type:
Command
- prepare_analysis_context(state, player)¶
Prepare context for position analysis.
- Parameters:
state (MancalaState) – Current game state.
player (str) – The player making the analysis (‘player1’ or ‘player2’).
- Returns:
Context dictionary for position analysis.
- Return type:
Dict[str, Any]
- prepare_move_context(state, player)¶
Prepare context for move generation.
- Parameters:
state (MancalaState) – Current game state.
player (str) – The player making the move (‘player1’ or ‘player2’).
- Returns:
Context dictionary for move generation.
- Return type:
Dict[str, Any]
- run_game(visualize=True, debug=False)¶
Run a full Mancala game loop with optional visualization.
- Parameters:
- Returns:
Final game state after completion.
- Return type:
- setup_workflow()¶
Set up the game workflow.
Creates a dynamic graph with nodes for game initialization, move making, and analysis. Adds edges between nodes based on the current player’s turn.
- Return type:
None
- visualize_state(state)¶
Visualize the current game state.
- Parameters:
state – Either a MancalaState object or a dictionary with state data
- games.mancala.agent_original.ensure_game_state(state_input)¶
Ensure input is converted to MancalaState.
- Parameters:
state_input (dict[str, Any] | haive.games.mancala.state.MancalaState | langgraph.types.Command) – State input as dict, MancalaState, or Command
- Returns:
MancalaState instance
- Return type: