A few days ago I tweeted about boxcar2d.com, and since nobody said HOLY CRAP THAT’S THE MOST AMAZING THING EVER, I assume none of you went to look at it. Or maybe I’m just overexcited. The website is a program designed to simulate natural selection and evolution, using a track and a vast population of little cars. The program uses a physics engine called box2d as its base, so the cars have weight and size and speed as defined by a simple list of traits, and the goal is to get as far along the track as possible. the traits for each generation’s best cars are used to create the next generation, and thus, over time, the cars become better at navigating the track, and can go much farther.
What I love about this program is the wonderful way it emulates evolution as a combination of natural selection and mutation; it’s the most perfect illustration of how those concepts work together that I’ve ever seen, and it almost makes me want to be a biology teacher just so I can use it in class. The natural selection part is obvious: cars that perform better on a certain track will survive to pass on their traits to the next generation, thus providing continuity over time. If that’s all you had, though, the population would stagnate–eventually every car would be as good as the best car, but no better. Mutation guarantees that every now and then a new trait is introduced into the gene pool, and if it’s valuable it gets carried on, and if it’s not it disappears. Thus the species actually improves over time.
Let’s look at an example. The tracks the program uses are essentially a series of obstacles: Big Air is a set of progressively harder jumps, The Gap is a set of progressively wider potholes, Hang Ten is a set of progressively steeper hills, and so on. My favorite is Big Air, because it’s thrilling to watch the cars figure out how to clear the longer jumps, but for this example I’m going to use Blockhead, a straight, flat track blocked by a set of progressively bigger walls made of stacked bricks. Moving along the track requires knocking the walls down, moving over the fallen bricks, and so on.
Each population starts with a generation of completely random traits–they can be any shape, with any number of wheels attached to any number of points on the car. Most of these cars aren’t even recognizable as cars, and indeed most of them can’t even move; think of them as the single-celled organisms in the primordial soup. Some of my first-generation cars could actually move forward, usually on one wheel, either pushing their body ahead of them or pulling it behind them. Of these, most of them could knock down the first wall or two, but had trouble going any farther. This continued for a generation or two until one of the one-wheeled cars showed up with a wedge-shaped body, like the prow on the front of a train. This proved incredibly useful in plowing through the first several walls, and the car got farther along the track than any car before it. All of a sudden the next generation was filled with variants of this wedge, some more successful than others: one wedge was lower to the ground, digging under the blocks but eventually getting too buried to move; another wedge was so small that the wheel ended up flipping it around, using it like a mace, which knocked over walls with no problem but couldn’t get past the rubble. Over several generations the wedge refined itself into a blade-like triangle capable of plowing under the walls and knocking them over its back, and then one of these cars grew a second wheel. This proved much more useful than one, with much better ability to climb over piles of fallen blocks, and within a couple of generations the population was filled with sleek, two-wheeled blades that rammed the blocks at full speed and raced over the fallen debris. These cars proved useless against the heavier walls until another mutation showed up; many of the cars had developed third wheels here and there, sometimes giving them extra speed or stability, but the winning combination was a third wheel perched on a small spike in the front, jutting forward like a buzz saw, which knocked down all the walls before the main body of the car even got there, preparing the way for the two main wheels to just crawl over the wreckage. With this new adaptation the cars could travel much farther than ever before.
The previous paragraph evoked one of two reactions in you: either you were bored, and you’re still reading because your job is even more boring than this, or you were completely fascinated and already clicked the link at the top of the article. (I suppose technically there was a third group that got so bored they stopped reading altogether, but those people aren’t here anymore so I don’t have to talk to them. I can talk about them, though: what losers! How is this not the most fascinating thing you’ve ever seen?) One of the things you may have noticed in that description is the way the simulation demonstrates even the subtler aspects of evolution, such as increased complexity, increased efficiency, and the carrying on of key traits long after they become vestigial. The wedge-shaped bodies ceased to be important when the second wheel showed up, because the cars were no longer using them as plows to knock down walls, but they hung around anyway because there was no significant selection pressure to get rid of them. The human appendix is the same way: we don’t use it anymore, but people without one are pretty the same as people with one, so the trait never gets weeded out of the gene pool and we continue to produce babies with a useless extra organ.
When you try out the program, make sure to try it with several different tracks, because it’s fascinating to see which traits get selected for on which tracks. It’s also interesting to see which traits get selected for on every track: most cars will end up with two large wheels on the front and back, no matter which track you’re on, because it’s simply the most effective means of travel. This is another real-life analog: cows and crocodiles don’t share a lot of common ancestry, and thrive in very different environments, but they both have a head, body, tail, and four legs. Some shapes are just too efficient to not use.
To all of you science geeks: your welcome. To all the rest of you: thanks for reading anyway. I promise to talk about something more pertinent to your interests next time, probably a movie comparison between The Social Network and Jumper. I know that sounds weird, but seriously, it’s really interesting.