Some checks failed
Build Simulation and Test / Run All Tests (push) Failing after 14m52s
121 lines
3.5 KiB
Python
121 lines
3.5 KiB
Python
"""Simulation configuration classes for different modes."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Optional, Dict, Any
|
|
|
|
|
|
@dataclass
|
|
class EntityConfig:
|
|
"""Configuration for entity hyperparameters."""
|
|
|
|
# Global entity settings (apply to all entity types unless overridden)
|
|
max_acceleration: float = 0.125
|
|
max_angular_acceleration: float = 0.25
|
|
max_velocity: float = 1.0
|
|
max_rotational_velocity: float = 3.0
|
|
|
|
# Entity type specific configs (all entity parameters should be defined here)
|
|
entity_types: Dict[str, Dict[str, Any]] = field(default_factory=lambda: {
|
|
"default_cell": {
|
|
"reproduction_energy": 1700,
|
|
"starting_energy": 1000,
|
|
"interaction_radius": 50,
|
|
"drag_coefficient": 0.02,
|
|
"energy_cost_base": 1.5,
|
|
"neural_network_complexity_cost": 0.08,
|
|
"movement_cost": 0.25,
|
|
"food_energy_value": 140,
|
|
"max_visual_width": 10,
|
|
"reproduction_count": 2,
|
|
"mutation_rate": 0.05,
|
|
"offspring_offset_range": 10
|
|
}
|
|
})
|
|
|
|
|
|
@dataclass
|
|
class SimulationConfig:
|
|
"""Configuration for simulation setup."""
|
|
grid_width: int = 50
|
|
grid_height: int = 50
|
|
cell_size: int = 20
|
|
initial_cells: int = 50
|
|
initial_food: int = 500
|
|
food_spawning: bool = True
|
|
random_seed: int = 0
|
|
default_tps: float = 40.0
|
|
entities: EntityConfig = field(default_factory=EntityConfig)
|
|
|
|
|
|
@dataclass
|
|
class OutputConfig:
|
|
"""Configuration for data output."""
|
|
enabled: bool = True
|
|
directory: str = "simulation_output"
|
|
formats: List[str] = field(default_factory=lambda: ['json'])
|
|
collect_metrics: bool = False
|
|
collect_entities: bool = False
|
|
collect_evolution: bool = False
|
|
metrics_interval: int = 100
|
|
entities_interval: int = 1000
|
|
evolution_interval: int = 1000
|
|
real_time: bool = False
|
|
|
|
|
|
@dataclass
|
|
class HeadlessConfig:
|
|
"""Configuration for headless simulation mode."""
|
|
# Simulation settings
|
|
max_ticks: Optional[int] = None
|
|
max_duration: Optional[float] = None # seconds
|
|
early_stop: bool = False # Stop when 0 cells remaining
|
|
|
|
# Output settings
|
|
output: OutputConfig = field(default_factory=OutputConfig)
|
|
|
|
# Simulation core config
|
|
simulation: SimulationConfig = field(default_factory=SimulationConfig)
|
|
|
|
|
|
@dataclass
|
|
class InteractiveConfig:
|
|
"""Configuration for interactive simulation mode with UI."""
|
|
# Window settings
|
|
window_width: int = 0 # 0 = auto-detect
|
|
window_height: int = 0 # 0 = auto-detect
|
|
vsync: bool = True
|
|
resizable: bool = True
|
|
|
|
# UI settings
|
|
show_grid: bool = True
|
|
show_interaction_radius: bool = False
|
|
show_legend: bool = True
|
|
control_bar_height: int = 48
|
|
inspector_width: int = 260
|
|
properties_width: int = 320
|
|
console_height: int = 120
|
|
|
|
# Simulation core config
|
|
simulation: SimulationConfig = field(default_factory=lambda: SimulationConfig(initial_cells=350))
|
|
|
|
|
|
@dataclass
|
|
class ExperimentConfig:
|
|
"""Configuration for automated experiments."""
|
|
name: str = "experiment"
|
|
description: str = ""
|
|
|
|
# Multiple runs
|
|
runs: int = 1
|
|
run_duration: Optional[float] = None # seconds per run
|
|
run_ticks: Optional[int] = None # ticks per run
|
|
|
|
# Variables to test (for parameter sweeps)
|
|
variables: dict = field(default_factory=dict)
|
|
|
|
# Base configuration
|
|
base_config: HeadlessConfig = field(default_factory=HeadlessConfig)
|
|
|
|
# Output aggregation
|
|
aggregate_results: bool = True
|
|
aggregate_format: str = "csv" |