One of the things that’s always fascinated me the most about simulated evolution is the way in which simulated organisms have a tendency to exploit any loophole or weakness in your code for an evolutionary advantage. Although I’ve designed and attempted to design a handful of evolutionary simulations, I’d never until today seen an example of this Darwinian cleverness.
A few days ago, I threw together a simple little evolution simulator in NetLogo. Each of the agents in the simulation had three genes: xcor (position along the x-axis), ycor (position along the y-axis), breednum (the number of daughter agents it spawns when it reproduces), and killpropensity (how likely the agent is to kill a random nearby agent). The simulation produced some interesting — although not terribly fascinating — behavior: those agents that produced the most offspring had a tendency to dominate. There was an interesting dynamic between the “killer” agents and the “peaceful” agents. The killers tended to form low-density groups (since if any of them were too close together, they’d usually kill each other), while the “pacifists” formed dense blooms. For a while, the killers would hold back the pacifists, but eventually, the pacifists would encroach and squeeze out the killers altogether. A typical run looked like this:
The agents inherit the color of their parents, so the coloration isn’t exactly by “species,” but it’s pretty close. As you can see, the green agents are fast-breeding pacifists, rapidly encroaching on the slower-breeding killers toward the center.
Then — and this is where the unexpected behavior and exploitation of loopholes I was talking about comes in — I introduced a new variable: mutationrate. It controls, obviously enough, how rapidly the agents mutate. Very quickly, every run started to look like this:
As you can see, this blue species has very rapidly come to dominate. You can’t see it, but this species has a rather high mutation rate. It took me a while to figure out why the fast-mutators were at such an enormous advantage. Then, I remembered that, in this simulation, the agents were competing for space, and in such a competition, the fittest organisms would be the ones that can maximize the space filled by their offspring. Since x-position and y-position were treated as genes, they were being mutated right along with the other variables, and since a rapidly-mutating position allowed the agents to jump farther from their parents and fill space more rapidly, fast mutation was an enormous advantage. It was such an enormous advantage that, even though the extremely large mutations the fast-mutators experienced prevented the evolution of any other behavior (because those genes tended to get so randomized that they effectively didn’t get passed on), they were still far more successful than any of the other species.
After I corrected for this ludicrous advantage (by setting it so that mutation rate couldn’t work on the position genes), this is what I got:
For a moment, I thought I’d solved the problem, until I inspected some of the agents and discovered that they had stopped mutating altogether. The sneaky intelligence of the genetic algorithm strikes again! I suppose that mutating would become something of a maladaptive behavior once the organism had optimized all of its other behaviors, since, after optimization was reached, any organism that mutated could only be at a disadvantage.
I realized that the only fix for this would be to force the mutation rate to stay above 2 (it’s a peculiarity of the random-number-generation code I cobbled together for this simulation that, at a mutation rate less than 2, no mutations occur). I thought that all I’d get would be the simulation I started with, but I was pleasantly surprised to discover that there was actually quite a diversity of mutation rates, and that none of these rates was at a particularly huge advantage over any of the others. This is what a run of the fixed simulator produced:
Those numbers you see hovering over every agent are the mutation rate. It appears that there’s not really an advantage to having a mutation rate above the usual 2, but it does seem that there’s not a disadvantage, either. So I can finally call this simulation fixed.
This experience reminded me that there’s a reason genetic algorithms are so popular in AI research, and that brings us to the moral of this little story: Darwinian evolution is a lot smarter than us. When writing evolutionary simulations, if there’s a loophole or a workaround or an exploit to be found in your code, then evolution will find it. Plan accordingly.
NOTE: Someone requested an image with the organisms color-coded by “kill propensity.” Since you asked nicely, and since I agree that that would be a good image to have up here, here you go. The organisms that are the darkest have the lowest probability of killing their neighbors, and the ones that are closer to white are very likely to kill:
As you can see, the situation is as I described in the body of the post: the killers have too great a tendency to limit their own growth, and are easily out-competed by their more peaceful counterparts.