finds.dev← search

// the find

trekhleb/self-parking-car-evolution

★ 763 · TypeScript · MIT · updated Nov 2025

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

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.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →