haive.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¶

BaseGameConfig

Base configuration for all configurable games.

ConfigMode

Configuration mode for game setup.

GamePlayerRole

Definition of a player role in a game.

Functions¶

create_advanced_config(config_class, player_configs, ...)

Create a game configuration with detailed player configs.

create_example_config(config_class, example_name, **kwargs)

Create a game configuration from a predefined example.

create_llm_config(model, **kwargs)

Placeholder function until core factory is available.

create_simple_config(config_class, player1_model, ...)

Create a simple game configuration with model strings.

Module Contents¶

class haive.games.core.config.base.BaseGameConfig[source]¶

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()[source]¶

Build legacy hardcoded engines for backward compatibility.

Returns:

List of game engines using hardcoded LLM configurations

Return type:

list[Any]

configure_engines()[source]¶

Configure engines based on the determined mode.

Return type:

BaseGameConfig

abstractmethod create_engines_from_player_configs(player_configs)[source]¶

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)[source]¶

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()[source]¶

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()[source]¶

Automatically determine configuration mode based on provided fields.

Return type:

ConfigMode

abstractmethod get_example_configs()[source]¶

Define available example configurations.

Returns:

Dictionary mapping example names to configuration parameters

Return type:

dict[str, dict[str, Any]]

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

}

}

get_player_names()[source]¶

Get display names for all players.

Return type:

dict[str, str]

abstractmethod get_role_definitions()[source]¶

Define the player roles for this game.

Returns:

Dictionary mapping role names to GamePlayerRole definitions

Return type:

dict[str, GamePlayerRole]

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 haive.games.core.config.base.ConfigMode[source]¶

Bases: str, enum.Enum

Configuration mode for game setup.

Initialize self. See help(type(self)) for accurate signature.

class haive.games.core.config.base.GamePlayerRole(/, **data)[source]¶

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)

haive.games.core.config.base.create_advanced_config(config_class, player_configs, **kwargs)[source]¶

Create a game configuration with detailed player configs.

Parameters:
Returns:

Configured game instance

Return type:

BaseGameConfig

haive.games.core.config.base.create_example_config(config_class, example_name, **kwargs)[source]¶

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:

BaseGameConfig

haive.games.core.config.base.create_llm_config(model, **kwargs)[source]¶

Placeholder function until core factory is available.

Parameters:

model (str)

haive.games.core.config.base.create_simple_config(config_class, player1_model, player2_model, **kwargs)[source]¶

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:

BaseGameConfig