Overview
vector-race lets you hand-draw a race track over a traced reference image, then evolves a population of simple physics racers using a genetic algorithm to find the fastest sequence of moves around it.
Features
- Freehand track drawing over a traced reference photo, with closed-loop detection
- Start-line and end-line drawing, saved to a track file for reuse
- Genetic algorithm with configurable population size, survival rate, and mutation rate
- Collision detection against the drawn track boundary
- Per-racer movement trail rendering
- Live visualization of an entire generation racing simultaneously
How it works
Each racer is represented by a fixed-length sequence of discrete acceleration moves. The genetic algorithm selects the fastest racers from each generation as parents, recombines their move sequences with single-point crossover, and applies per-gene mutation to produce the next generation. Collisions are detected with a line-segment intersection test between each racer’s movement vector and the track boundary, and fitness combines time to finish with final distance to the end line.
