finds.dev

trekhleb/self-parking-car-evolution

🧬 Training the car to do self-parking using a genetic algorithm

View on GitHubHomepage ↗

★ 763TypeScriptMITupdated Nov 2025

// the take

A browser-only demo that evolves a population of cars to parallel-park using a genetic algorithm, rendered with Three.js/react-three-fiber and physics via cannon-es. It's aimed at people who want to see a GA work end-to-end on a visual, intuitive problem rather than at anyone needing a reusable GA library.

The actual genetic algorithm (genome encoding, mutation, fitness) lives in src/libs and is under 500 lines, cleanly separated from the ~92% of the codebase that's 3D/UI plumbing, so you can read the interesting part without wading through Three.js setup. It has real unit tests for the math primitives (sigmoid, polynomial, probability, geometry) and for the car-specific genetic logic, which is more rigor than most educational demos bother with. Pre-trained checkpoints are included so you can load a working population instead of waiting through generations from scratch.

The GA implementation is hard-wired to this domain (car genome shape, sensor-based fitness function) — there's no clean seam for lifting it out to solve a different optimization problem without a rewrite. Training runs single-threaded in the main browser thread with only per-generation localStorage checkpointing, so larger populations or longer runs will visibly stall the UI and can't resume mid-generation. There's no CI workflow in the repo, so the existing tests aren't enforced on contributions. Core dependencies (CRA, cannon-es, react-three-fiber) are pinned to versions from the project's original build and will need real work to bring current.

We read the README, the directory tree and a key source file in September 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
763
Forks
87
Language
TypeScript
License
MIT
Last commit
23 Nov 2025

// nearby

If self-parking-car-evolution isn't quite it.

All repos →