Files
maze-ml/config.py
kerboul 45b37f9357 fix: genome GA converges via BFS fitness + two-rate prefix-aware mutation
- Replace Manhattan distance with BFS distances (actual maze path length)
- Switch from NN to direct sequence genome (what YouTube Shorts actually use)
- Mutation-only GA (crossover breaks positional maze paths)
- Two-rate mutation: low rate before best-step (preserve prefix), high after (explore tail)
- Auto-seed selection finds maze with short BFS path
- Default maze 15x15, cell_size=36, max_steps=150
- Typically converges in 5-15 generations
2026-06-13 15:48:22 +02:00

34 lines
898 B
Python

from dataclasses import dataclass
@dataclass
class MazeConfig:
# Maze geometry
maze_cols: int = 15
maze_rows: int = 15
cell_size: int = 36
wall_width: int = 2
# GA / Training
population: int = 100
max_steps: int = 150
elite_frac: float = 0.30
n_elite: int = 3 # few elites → maintains population diversity
mutation_std: float = 0.08
mutation_rate: float = 0.35
temperature: float = 0.7 # softmax sampling temperature (lower = more greedy)
# Neural net — 14 inputs: 4 walls + 2 goal dir + 2 pos + 4 last-action + 1 blocked + 1 revisit
n_inputs: int = 14
n_hidden: int = 16
n_outputs: int = 4
# Fitness
goal_bonus: float = 1000.0
step_penalty: float = 0.01
# Rendering
fps: int = 60
trail_decay: float = 0.88
window_title: str = "Maze ML — GA Visualizer"
hud_font_size: int = 18