I made a science
After watching a few more videos by and about creationists on the YouTube, I realised that not only do I have more computing power at my fingertips than most scientists in history could ever have dreamed of and a greater-than-average ability to use said power, I also have a neat, educational, and easily implemented project to use it for.
Perhaps you remember the weasel program, but in case you don’t, here’s how my implementation worked:
The user enters a string consisting of characters from a certain pool (in our case, just capital letters and spaces). The program generates a random string of character from that pool, of the same length as the string the user entered. Every “generation”, the program takes one character in that string at random, and replaces it with another random character from the pool; it then compares the new (offspring) string and the old (parent) string to the target string the user entered, and discards the string that’s least like the target. The other one goes on to be the parent in the next generation.
This continues until the program’s own initially random string matches the user’s.
It’s a very simplistic example of Darwinian evolution, and while the point of it can be missed by people aiming to miss it, it demonstrates the power of evolution quite well.
Of course, casually running the program, seeing the number, and nodding absent-mindedly before forgetting all about it is no way to treat a nice algorithm, so I decided to drive the point home by modifying it a bit.
I decided to do a series of tests with successively longer strings (starting with one character, working up to fifty), and record how long it took on average to get from the random starting string to the target string (which is now just a series of As; I hope you realise why this doesn’t matter). The pool of characters was brought down from 27 possible characters to 10, to speed up execution times1, and each test was then run five thousand times, to get rid of statistical artifacts.
The results were then plotted on a graph:

The X axis is the length of the string. The Y axis is the number of generations it took to get from a random starting string to the target. The blue line is the results my program found. The red line is how long you’d expect to take on average if you just rerolled the string entirely, which is how most creationists seem to think evolution works (the “tornado through a junkyard” fallacy).
For a string of length 50 this number is (1050)/2, so forgive me for cutting it off the graph pretty early on.
There are some odd spikes the large sample size should have gotten rid of, which I blame on java.util.Random crapping out2, but the trend is pretty clear all the same. (Edit: yeah, the problem was indeed that, and specifically how Java caches things in ways that breaks seeding random number generators. I fixed the issue as best I could and ran the program again; the results are here, and the spikes are indeed gone.)
It took about half an hour to run on my laptop, and the results are even clearer than I expected. Rather than the exponential growth in the number of generations needed so many creationists “predict”, there’s a linear one, which is much healthier.
You can debate how directly this applies to real-life evolution, since organisms tend to have genomes rather larger than fifty base pairs (though their pool of characters is only four, not ten), but they also tend to have more than one kid, and evolution is a trend over an entire population, not just one lineage, and they tend to have more than one mutation per generation (not to mention a bunch of other ways to stir things up, like chromosomal crossover), and sexual reproduction makes a whole new mess of everything.
The point, though, is to show the power of the Darwinian process; specifically, that it’s not just random chance, but something much, much more powerful.
Of course, people can show you all kinds of graphs and give you all kinds of programs to run, but it’s much more satisfying if you do it yourself and understand what you’re doing.
So I’m not going to post my code. Do it yourself. You have the algorithm (and if you think it sucked, improve on it (and post in the comments)), write your own code. It’s simple enough, it’s fun, and it’s quite gratifying.
1 I also made a multi-threaded version of the program which works with a pool of fifty characters and goes up to string lengths of 500, and it’s been running on my reasonably pathetic cluster for the past two hours. I expect it to finish in a few weeks, unless the fans give out again and the entire cluster shuts down.
2 ENTERPRISE TURKEY SOLUTIONS




This took a while to finish. In part because I’m reading too many books at once, but also because it’s so depressing I had to put it down a few times.