haive.games.chess.dynamic_config¶

Dynamic configuration for chess game.

This module provides a flexible configuration system for chess that supports: - Legacy hardcoded engines (backward compatibility) - Simple model string configuration - Example-based configuration - Advanced PlayerAgentConfig configuration

Classes¶

ChessConfig

Dynamic configuration for chess game.

Functions¶

budget_chess(**kwargs)

Create a budget-friendly chess configuration.

competitive_chess(**kwargs)

Create a competitive chess configuration with top models.

create_chess_config([white_model, black_model])

Create a chess configuration with simple model strings.

create_chess_config_from_example(example_name, **kwargs)

Create a chess configuration from a predefined example.

create_chess_config_with_players(player_configs, **kwargs)

Create a chess configuration with detailed player configs.

create_legacy_chess_config(**kwargs)

Create a chess configuration using legacy hardcoded engines.

experimental_chess(**kwargs)

Create an experimental chess configuration with mixed providers.

Module Contents¶

class haive.games.chess.dynamic_config.ChessConfig¶

Bases: haive.games.core.config.BaseGameConfig

Dynamic configuration for chess game.

This configuration supports multiple modes: 1. Legacy: Use hardcoded engines from engines.py 2. Simple: Specify models as strings (white_model, black_model) 3. Example: Use predefined configurations (e.g., “gpt_vs_claude”) 4. Advanced: Full PlayerAgentConfig specifications

white_model¶

Model for white player (simple mode)

black_model¶

Model for black player (simple mode)

white_player_name¶

Display name for white player

black_player_name¶

Display name for black player

max_moves¶

Maximum moves before draw (default: 200)

enable_fen_visualization¶

Show FEN strings in analysis

build_legacy_engines()¶

Build legacy hardcoded engines.

Return type:

list[Any]

create_engines_from_player_configs(player_configs)¶

Create engines from player configurations.

Parameters:

player_configs (dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig])

Return type:

list[Any]

create_simple_player_configs()¶

Create player configs from simple model strings.

Return type:

dict[str, haive.games.core.agent.player_agent.PlayerAgentConfig]

get_example_configs()¶

Define example chess configurations.

Return type:

dict[str, dict[str, Any]]

get_role_definitions()¶

Define chess player roles.

Return type:

dict[str, haive.games.core.config.GamePlayerRole]

haive.games.chess.dynamic_config.budget_chess(**kwargs)¶

Create a budget-friendly chess configuration.

Return type:

ChessConfig

haive.games.chess.dynamic_config.competitive_chess(**kwargs)¶

Create a competitive chess configuration with top models.

Return type:

ChessConfig

haive.games.chess.dynamic_config.create_chess_config(white_model='gpt-4o', black_model='claude-3-5-sonnet-20240620', **kwargs)¶

Create a chess configuration with simple model strings.

Parameters:
  • white_model (str) – Model for white player

  • black_model (str) – Model for black player

  • **kwargs – Additional configuration parameters

Returns:

ChessConfig instance

Return type:

ChessConfig

Examples

>>> config = create_chess_config("gpt-4", "claude-3-opus")
>>> config = create_chess_config(
...     "openai:gpt-4o",
...     "anthropic:claude-3-5-sonnet",
...     temperature=0.8
... )
haive.games.chess.dynamic_config.create_chess_config_from_example(example_name, **kwargs)¶

Create a chess configuration from a predefined example.

Parameters:
  • example_name (str) – Name of the example configuration

  • **kwargs – Additional parameters to override

Returns:

ChessConfig instance

Return type:

ChessConfig

Available examples:
  • “gpt_vs_claude”: GPT-4 vs Claude

  • “anthropic_vs_openai”: Claude vs GPT showdown

  • “gpt_only”: GPT-4 for both players

  • “claude_only”: Claude for both players

  • “budget”: Cost-effective models

  • “mixed”: Different providers

Examples

>>> config = create_chess_config_from_example("budget")
>>> config = create_chess_config_from_example("gpt_vs_claude", max_moves=150)
haive.games.chess.dynamic_config.create_chess_config_with_players(player_configs, **kwargs)¶

Create a chess configuration with detailed player configs.

Parameters:
Returns:

ChessConfig instance

Return type:

ChessConfig

Expected roles:
  • “white_player”: White player configuration

  • “black_player”: Black player configuration

  • “white_analyzer”: White analyzer configuration (optional)

  • “black_analyzer”: Black analyzer configuration (optional)

Examples

>>> player_configs = {
...     "white_player": PlayerAgentConfig(
...         llm_config="gpt-4",
...         temperature=0.7,
...         player_name="Aggressive White"
...     ),
...     "black_player": PlayerAgentConfig(
...         llm_config="claude-3-opus",
...         temperature=0.3,
...         player_name="Defensive Black"
...     )
... }
>>> config = create_chess_config_with_players(player_configs)
haive.games.chess.dynamic_config.create_legacy_chess_config(**kwargs)¶

Create a chess configuration using legacy hardcoded engines.

This is for backward compatibility with existing code.

Parameters:

**kwargs – Additional configuration parameters

Returns:

ChessConfig instance with hardcoded engines

Return type:

ChessConfig

haive.games.chess.dynamic_config.experimental_chess(**kwargs)¶

Create an experimental chess configuration with mixed providers.

Return type:

ChessConfig