Skip to content

eclipse1605/pendulum-neat

Repository files navigation

Pendulum-NEAT

Evolve NEAT neural-network controllers that balance a double inverted pendulum on a cart, with curriculum learning and an interactive Viz Studio web demo.

Try in 60 seconds

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Quick training smoke (configs/demo.toml)
pendulum-neat train --config configs/demo.toml

# Full training run (configs/full.toml — ~200 pop, curriculum, parallel eval)
pendulum-neat train --config configs/full.toml

# Evaluate a checkpoint
pendulum-neat eval --checkpoint output/runs/<run>/best_genome.pkl

# Interactive Viz Studio (Three.js + FastAPI)
pendulum-neat serve --open

Pre-baked demo assets in assets/ work offline in replay mode when the server is unavailable.

Commands

Command Description
pendulum-neat train NEAT training with curriculum
pendulum-neat train --resume PATH Resume from population checkpoint
pendulum-neat eval --checkpoint PATH Print fitness metrics
pendulum-neat serve Launch Viz Studio in browser
pendulum-neat record -o assets/ Export trajectory + network JSON
pendulum-neat export-network Export network topology JSON

Architecture

  • pendulum_neat/ — Evaluator, CheckpointStore, TrainingRun, CLI
  • neat/ — NEAT algorithm (speciation, crossover, mutation)
  • physics/ — RK4 double-pendulum simulation
  • viz/ — Trajectory recorder + network graph JSON
  • server/ — FastAPI WebSocket sim backend
  • web/dist/ — Viz Studio frontend (Three.js)

See docs/ARCHITECTURE.md for data flow.

Curriculum

  1. Start with low gravity + high friction
  2. Advance when time_above ≥ threshold for N consecutive generations
  3. Ramp toward full physics difficulty

Configure in config.toml under [curriculum].

Outputs

Each training run writes to output/runs/<timestamp>/:

  • metrics.jsonl — per-generation stats
  • checkpoint_final.pkl — resumable population
  • best_genome.pkl — best evolved controller
  • training_progress.png — fitness plot
  • clips/ — optional trajectory JSON recordings

Tech stack

Python · NumPy · NEAT · RK4 physics · FastAPI · Three.js · pytest · GitHub Actions

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages