games.single_player.agent¶

Single-player game agent base class.

This module provides the SinglePlayerGameAgent base class for implementing single-player game agents in the Haive framework.

Classes¶

SinglePlayerGameAgent

Base class for single-player game agents.

Module Contents¶

class games.single_player.agent.SinglePlayerGameAgent(config)¶

Bases: haive.games.base.agent.GameAgent[T]

Base class for single-player game agents.

This class extends GameAgent to provide specific functionality for single-player games where an LLM can act as the player, assistant, or game engine.

Single-player games differ from multiplayer games in that they: - Don’t require turn management between multiple players - Often involve puzzles, challenges, or solo adventures - May use the LLM as a game master or narrator

Example

>>> from haive.games.single_player import SinglePlayerGameAgent
>>> class WordleAgent(SinglePlayerGameAgent):
...     def __init__(self, config):
...         super().__init__(config)
...         self.state_manager = WordleStateManager
config¶

Configuration for the single-player game

state_manager¶

Manager for game state transitions

Initialize the single-player game agent.

Parameters:

config (T) – Game-specific configuration

abstractmethod generate_game_response(state)¶

Generate the game’s response to the current state.

Parameters:

state (dict) – Current game state

Returns:

Game’s response or narration

Return type:

str

abstractmethod handle_player_action(action)¶

Handle a player action in the game.

Parameters:

action (str) – The player’s action as a string

Returns:

Result of the action including any state changes

Return type:

dict

setup_single_player_workflow()¶

Set up the workflow specific to single-player games.

This method can be overridden by subclasses to customize the workflow for specific single-player game mechanics.

Return type:

None