wip: main.py
This commit is contained in:
9
main.py
9
main.py
@@ -47,7 +47,7 @@ def main():
|
||||
parser = argparse.ArgumentParser(description="Maze ML — Genetic Algorithm Visualizer")
|
||||
parser.add_argument("--fast", action="store_true", help="Train without rendering (headless)")
|
||||
parser.add_argument("--generations", type=int, default=200)
|
||||
parser.add_argument("--maze-size", type=int, default=25, help="Maze cols and rows (square)")
|
||||
parser.add_argument("--maze-size", type=int, default=15, help="Maze cols and rows (square)")
|
||||
parser.add_argument("--seed", type=int, default=None)
|
||||
parser.add_argument("--speed", type=int, default=60, help="FPS cap for visual mode")
|
||||
parser.add_argument("--steps-per-frame", type=int, default=3, help="Simulation steps rendered per frame (higher = faster)")
|
||||
@@ -69,6 +69,13 @@ def main():
|
||||
if path_len > cfg.maze_rows * cfg.maze_cols // 3:
|
||||
print(f" [hint: long path ({path_len} steps) -- try omitting --seed for auto-selection]")
|
||||
|
||||
# Genome must be at least 3× the BFS path or GA will never converge
|
||||
bfs_path = int(bfs[0, 0])
|
||||
needed = bfs_path * 3
|
||||
if needed > cfg.max_steps:
|
||||
cfg.max_steps = needed
|
||||
print(f"Genome length adapted: max_steps={cfg.max_steps} (BFS={bfs_path}×3)")
|
||||
|
||||
def make_agents(genomes):
|
||||
agents = [Agent(g, 0, 0) for g in genomes]
|
||||
for a in agents:
|
||||
|
||||
Reference in New Issue
Block a user