Thursday, February 17

Boxcar 2D

Below, a nifty program designed by Derp Bike Designer, learns to build a "car" using a genetic algorithm - the clip in its advanced stages. It starts with a population of 20 randomly generated shapes with wheels and runs each one to see how far it goes. The cars that go the furthest reproduce to produce offspring for the next generation. The offspring combine the traits of the parents to hopefully produce better cars.


It uses a physics library to simulate the effects of gravity, friction, collisions, motor torque, and spring tension for the car. This lets the car be a wide range of shapes and sizes, while still making the simulation realistic. There are also many extra variables because of the complicated car and axles and the color clearly illustrates the evolution.

Eric adds further: "initially the components are assembled randomly. different variables affect the wheel sizes, hub heights, etc.cars that fare better pass their genes along preferentially. over time they settle on optimal designs. it illustrates an software technique known as a genetic algorithm---the analogy to darwinian evolution is strong."