haive.games.connect4.agent¶
Agent for playing Connect 4.
This module defines the Connect 4 agent, which uses language models to generate moves and analyze positions in the game.
Classes¶
Agent for playing Connect 4. |
Module Contents¶
- class haive.games.connect4.agent.Connect4Agent(config)[source]¶
Bases:
haive.games.framework.base.agent.GameAgent
[haive.games.connect4.config.Connect4AgentConfig
]Agent for playing Connect 4.
This class implements the Connect 4 agent, which uses language models to generate moves and analyze positions in the game.
Init .
- Parameters:
config (haive.games.connect4.config.Connect4AgentConfig) – [TODO: Add description]
- analyze_player1(state)[source]¶
Analyze position for the red player.
This method analyzes the position for the red player in the current game state.
- Parameters:
- Return type:
langgraph.types.Command
- analyze_player2(state)[source]¶
Analyze position for the yellow player.
This method analyzes the position for the yellow player in the current game state.
- Parameters:
- Return type:
langgraph.types.Command
- extract_move(response)[source]¶
Extract move from engine response.
This method extracts the move from the engine response.
- Parameters:
response (haive.games.connect4.models.Connect4PlayerDecision)
- Return type:
- make_player1_move(state)[source]¶
Make a move for the red player.
This method makes a move for the red player in the current game state.
- Parameters:
- Return type:
langgraph.types.Command
- make_player2_move(state)[source]¶
Make a move for the yellow player.
This method makes a move for the yellow player in the current game state.
- Parameters:
- Return type:
langgraph.types.Command
- prepare_analysis_context(state, player)[source]¶
Prepare context for position analysis with correct variables.
This method prepares the context for position analysis by calculating threats and formatting the required fields.
- Parameters:
player (str)
- Return type:
- prepare_move_context(state, player)[source]¶
Prepare context for move generation.
This method prepares the context for move generation by formatting the legal moves and getting the player’s last analysis.
- Parameters:
player (str)
- Return type: