A while ago, I found something entitled Biomorphs, which appeared to be a bunch of random drawings created by some sort of computer program. I began investigating this a bit further, and found out this was actually the result of running a popular AI type program, which is carrying out an algorithm described by Richard Dawkins from his "The Blind Watchman" book, entitled BIOMORPHS.
Dawkins investigated the possibilities inherent in just the combination of mutation and selection, when combined with a very powerful development (decoding) process.
This is basically a recursive algorithm that has some genes and uses some mutation and some random selection. That's it. That is all that is required to produce a wide variety of fascinating virtual creatures, some which look very genetic.
Dawkins Basic System
The phenotypes (how it looks) in Dawkins system were essentially branching tree structures. An extension is to add segments to this (this is not included in this article).
The basic system has nine genes, controlling things like:
- angle of branching
- depth of branching
- number of lines
- etc. etc.
It makes use of a recursive algorithm to carry out the drawing; this is shown below:
private void draw(Graphics g, int i, int j)
tree(g, i / 2, j, order, 2);
private void tree(Graphics g, int i, int j, int k, int l)
if (l < 0)
l += 8;
if (l >= 8)
l -= 8;
int i1 = i + k * dx[l];
int j1 = j - k * dy[l];
g.DrawLine(new Pen(new SolidBrush(Color.White), 1.8F), i, j, i1, j1);
if (k > 0)
tree(g, i1, j1, k - 1, l - 1);
tree(g, i1, j1, k - 1, l + 1);
Using this algorithm, it is possible to come up with some really interesting creatures such as:
They look very organic, don't they? However, if we introduce a segmentation (not done for this article) to the algorithm, we can then achieve some truly bizarre creatures such as these. Basically, we are using the same idea, but we are creating more segments of the same basic shape.
The following diagram illustrates the code design. I will give a brief discussion on each class before I show the demonstration screenshots.
Basically, there are two types of bio-morphs that I created for this article. These are:
- BioMorph, which makes use the the following classes:
BiomorphPanel: Which provides the rendering for the original Dawkins Biomorph.
IBioEvolvalbe: An interface which is implemented by the
BiomorphLayoutPanel: Hosts a number of
BiomorphPanel objects. This is then hosted on a Windows Form, and it is responsible for the selection of a random
BiomorphPanel, to spawn a new generation of Dawkins Biomorphs.
- EvolvingCritter, which makes use the the following classes:
EvolvingCritterPanel: Which provides the rendering for a Cow Skull type Biomorph.
IEvolvalbe: An interface which is implemented by the
CritterLayoutPanel: Hosts a number of
EvolvingCritterPanel objects. This is then hosted on a Windows Form, and it is responsible for the selection of the fittest
EvolvingCritterPanel, to spawn a new generation of Dawkins Biomorphs.
EvolvingCritterComparator: Provides a simple implementation of
IComparer, to allow a collection of
EvolvingCritterPanel objects to be sorted in order to obtain the fittest one.
There is also a common interface:
ILayoutPanel: which is implemented by both
CritterLayoutPanel, which allows the Windows Form where one of these two panels is hosted to generate a new population of organisms.
Screenshots of the Running Application
OK, so what does the application look like? Well, it depends on which of the Biomorphs is currently in use. Basically, there are two links, and depending on which one is selected, the main panel will be swapped to show the correct Biomorphs panel. It will either be a
BiomorphLayoutPanel (Dawkins Biomorphs), or a
CritterLayoutPanel (my own Cow Skull Biomorphs). Let's have a look at this, shall we?
Using Dawkins BiomorphLayoutPanel BioMorphs
There is a timer placed on the form which, every 1500 milliseconds, will choose a random Dawkins Biomorph, and will use that to spawn a new population of crazy critters. There is only random selection (no tricks), and you can get some very bio-logical looking critters. Basically, it's all down to the clever gene decoding we saw earlier.
Using CritterLayoutPanel BioMorphs (My Own Cow Skull Design)
I really only included the possibility to create other style Biomorphs for a bit of fun. The difference here is that these chaps are judged to see which one should be the one that is used for breeding. Basically, the one with the most area, and the preferred eye color, and the preferred constituent parts, will have a better score, so it will more likely be the alpha male that will be used for breeding.
Note: We do actually pick the fittest one here, so one would hope that over time, we would end up with similar shaped or colored organisms. But nature has other ideas, mutation is very powerful. Play with it a while and you will see.
Freedom of Choice
With both these Biomorph panels, the user is also free to click on the organism they like; then this will be used as the new alpha male that is then used to create a new population.
What Do You Think?
That's it. I would just like to ask, if you liked the article, please vote for it.
I have quite enjoyed constructing this article. I hope you liked it.