Reference
Genome Evaluation and Fitness
Look up syntax, contracts, layouts, algorithms, and exact behavior.
Each genome is evaluated by creating a fresh Matter.js engine, placing the ball at the launch point, applying the genome as initial velocity, and stepping the world for a fixed number of frames. During the replay, the simulator records the path, the minimum distance to the target, whether the ball hit the target, and when the hit occurred.
The fitness function strongly rewards hits, especially early hits. Misses are still ranked by closeness, with a small travel-distance tie breaker so that useful motion beats a static failure.
That discontinuity is deliberate. Near misses should guide the population before it discovers the target, but once any genome actually overlaps the target, the search should rapidly prefer true hits over merely elegant arcs. The early-hit bonus then breaks ties among successful shots by favoring simpler, faster trajectories.