games.core.config.base¶
Base configuration classes for configurable games.
from typing import Any This module provides the foundation for creating flexible game configurations that support multiple LLM providers and configuration modes.
Classes¶
Base configuration for all configurable games. |
|
Configuration mode for game setup. |
|
Definition of a player role in a game. |
Functions¶
|
Create a game configuration with detailed player configs. |
|
Create a game configuration from a predefined example. |
|
Placeholder function until core factory is available. |
|
Create a simple game configuration with model strings. |
Module Contents¶
- class games.core.config.base.BaseGameConfig¶
Bases:
haive.core.engine.agent.agent.AgentConfig
,abc.ABC
Base configuration for all configurable games.
This class provides a unified configuration system that supports: - Legacy hardcoded engines (backward compatibility) - Simple model string configuration - Example-based configuration - Advanced PlayerAgentConfig configuration
Games should extend this class and implement the required abstract methods.
- abstractmethod build_legacy_engines()¶
Build legacy hardcoded engines for backward compatibility.
- Returns:
List of game engines using hardcoded LLM configurations
- Return type:
list[Any]
- configure_engines()¶
Configure engines based on the determined mode.
- Return type:
- abstractmethod create_engines_from_player_configs(player_configs)¶
Create engines from detailed player configurations.
- Parameters:
player_configs (dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]) – Dictionary mapping role names to PlayerAgentConfig
- Returns:
List of configured game engines
- Return type:
list[Any]
- create_example_player_configs(example_name)¶
Create player configs from example configuration.
- Parameters:
example_name (str)
- Return type:
dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]
- create_simple_player_configs()¶
Create player configs from simple model strings.
This method should be overridden by games that use different field names (e.g., white_model/black_model instead of player1_model/player2_model).
- Return type:
dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]
- determine_config_mode()¶
Automatically determine configuration mode based on provided fields.
- Return type:
- abstractmethod get_example_configs()¶
Define available example configurations.
- Returns:
Dictionary mapping example names to configuration parameters
- Return type:
Examples
- {
- “gpt_vs_claude”: {
“player1_model”: “gpt-4”, “player2_model”: “claude-3-opus”, “temperature”: 0.7
}, “budget”: {
“player1_model”: “gpt-3.5-turbo”, “player2_model”: “gpt-3.5-turbo”, “temperature”: 0.5
}
}
- abstractmethod get_role_definitions()¶
Define the player roles for this game.
- Returns:
Dictionary mapping role names to GamePlayerRole definitions
- Return type:
Examples
- {
“white_player”: GamePlayerRole(name=”white_player”, display_name=”White”), “black_player”: GamePlayerRole(name=”black_player”, display_name=”Black”), “white_analyzer”: GamePlayerRole(name=”white_analyzer”, display_name=”White Analyst”, is_analyzer=True), “black_analyzer”: GamePlayerRole(name=”black_analyzer”, display_name=”Black Analyst”, is_analyzer=True),
}
- class games.core.config.base.ConfigMode¶
-
Configuration mode for game setup.
Initialize self. See help(type(self)) for accurate signature.
- class games.core.config.base.GamePlayerRole(/, **data)¶
Bases:
pydantic.BaseModel
Definition of a player role in a game.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- games.core.config.base.create_advanced_config(config_class, player_configs, **kwargs)¶
Create a game configuration with detailed player configs.
- Parameters:
config_class (type[BaseGameConfig]) – The game’s configuration class
player_configs (dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]) – Dictionary mapping role names to PlayerAgentConfig
**kwargs – Additional configuration parameters
- Returns:
Configured game instance
- Return type:
- games.core.config.base.create_example_config(config_class, example_name, **kwargs)¶
Create a game configuration from a predefined example.
- Parameters:
config_class (type[BaseGameConfig]) – The game’s configuration class
example_name (str) – Name of the example configuration
**kwargs – Additional configuration parameters to override
- Returns:
Configured game instance
- Return type:
- games.core.config.base.create_llm_config(model, **kwargs)¶
Placeholder function until core factory is available.
- Parameters:
model (str)
- games.core.config.base.create_simple_config(config_class, player1_model, player2_model, **kwargs)¶
Create a simple game configuration with model strings.
- Parameters:
config_class (type[BaseGameConfig]) – The game’s configuration class
player1_model (str) – Model for player 1
player2_model (str) – Model for player 2
**kwargs – Additional configuration parameters
- Returns:
Configured game instance
- Return type: