haive.games.framework.multi_player.factory¶

Factory for creating multi-player game agents.

This module provides a factory class for creating multi-player game agents, automating the creation of game-specific agent classes with proper configuration and state management.

Example

>>> from haive.agents.agent_games.framework.multi_player.factory import MultiPlayerGameFactory
>>>
>>> # Create a new chess agent class
>>> ChessAgent = MultiPlayerGameFactory.create_game_agent(
...     name="ChessAgent",
...     state_schema=ChessState,hv
...     state_manager=ChessStateManager,
...     player_roles=["white", "black"],
...     aug_llm_configs={
...         "white": {"move": white_llm_config},
...         "black": {"move": black_llm_config}
...     }
... )

Classes¶

MultiPlayerGameFactory

Factory for creating multi-player game agents.

Module Contents¶

class haive.games.framework.multi_player.factory.MultiPlayerGameFactory[source]¶

Factory for creating multi-player game agents.

This class provides static methods for creating game-specific agent classes with proper configuration and state management. It handles:

  • Agent class creation with proper inheritance

  • Configuration class creation

  • State management integration

  • Custom method injection

  • Agent registration

Example

>>> # Create a new game agent class
>>> MafiaAgent = MultiPlayerGameFactory.create_game_agent(
...     name="MafiaAgent",
...     state_schema=MafiaState,
...     state_manager=MafiaStateManager,
...     player_roles=["villager", "mafia", "detective"],
...     aug_llm_configs={
...         "villager": {"vote": villager_config},
...         "mafia": {"kill": mafia_config},
...         "detective": {"investigate": detective_config}
...     }
... )
static create_game_agent(name, state_schema, state_manager, player_roles, aug_llm_configs, custom_methods=None)[source]¶

Create a new multi-player game agent class.

This method creates a new agent class with proper configuration, state management, and custom methods. The created class is automatically registered with the agent registry.

Parameters:
  • name (str) – Name of the agent class.

  • state_schema (Type[MultiPlayerGameState]) – The game state schema class.

  • state_manager (Type[MultiPlayerGameStateManager]) – The game state manager class.

  • player_roles (List[str]) – List of player roles.

  • aug_llm_configs (Dict[str, Dict[str, AugLLMConfig]]) – LLM configurations by role and function.

  • custom_methods (Dict[str, Callable], optional) – Additional methods for the agent.

Returns:

A new agent class ready for instantiation.

Return type:

Type[Agent]

Example

>>> # Create a chess agent with custom methods
>>> ChessAgent = MultiPlayerGameFactory.create_game_agent(
...     name="ChessAgent",
...     state_schema=ChessState,
...     state_manager=ChessStateManager,
...     player_roles=["white", "black"],
...     aug_llm_configs={
...         "white": {"move": white_config},
...         "black": {"move": black_config}
...     },
...     custom_methods={
...         "evaluate_position": my_eval_function,
...         "get_piece_moves": my_move_generator
...     }
... )