109 lines
3.0 KiB
Python
109 lines
3.0 KiB
Python
"""Simulation configuration classes for different modes."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
from config.constants import *
|
|
|
|
|
|
@dataclass
|
|
class SimulationConfig:
|
|
"""Configuration for simulation setup."""
|
|
grid_width: int = GRID_WIDTH
|
|
grid_height: int = GRID_HEIGHT
|
|
cell_size: int = CELL_SIZE
|
|
initial_cells: int = 50
|
|
initial_food: int = FOOD_OBJECTS_COUNT
|
|
food_spawning: bool = FOOD_SPAWNING
|
|
random_seed: int = RANDOM_SEED
|
|
default_tps: float = DEFAULT_TPS
|
|
|
|
|
|
@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
|
|
|
|
# Output settings
|
|
output: OutputConfig = field(default_factory=OutputConfig)
|
|
|
|
# Simulation core config
|
|
simulation: SimulationConfig = field(default_factory=lambda: SimulationConfig(
|
|
grid_width=GRID_WIDTH,
|
|
grid_height=GRID_HEIGHT,
|
|
cell_size=CELL_SIZE,
|
|
initial_cells=50,
|
|
initial_food=FOOD_OBJECTS_COUNT,
|
|
food_spawning=FOOD_SPAWNING,
|
|
random_seed=RANDOM_SEED,
|
|
default_tps=DEFAULT_TPS
|
|
))
|
|
|
|
|
|
@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(
|
|
grid_width=GRID_WIDTH,
|
|
grid_height=GRID_HEIGHT,
|
|
cell_size=CELL_SIZE,
|
|
initial_cells=350,
|
|
initial_food=FOOD_OBJECTS_COUNT,
|
|
food_spawning=FOOD_SPAWNING,
|
|
random_seed=RANDOM_SEED,
|
|
default_tps=DEFAULT_TPS
|
|
))
|
|
|
|
|
|
@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" |