WARNING! This page is out-of-date. Go here for the latest versions.


The applet runs slowly when your mouse pointer is within the area, quickly when it is outside. This is so you can slow things down if you want to.

This applet is an approximate simulation of DNA replication. Each coloured square is a molecule, the black lines represent a chemical bond between two molecules. Each molecule moves around at random, with the restriction that bonds cannot extend more than a certain distance. Simple chemical rules determine when bonds are formed and when they are broken (reactions). The effect of these reactions is to cause the string of coloured squares to replicate itself repeatedly, as long as there are sufficient free molecules available.

This code grew out of earlier work on mobile cellular automata and through discussion with Daniel LaLiberte and others on the Primordial Life discussion group.

The aim is to create a chemistry that permits robust, adaptable self-replicators. If it can be shown that self-replicators with varying fitness can exist, then in the presence of mutations and under the pressures of natural selection, evolutionary processes should be observed.

Get involved! You can have the source code for this if you want. Some details about how Squirm3 works are below.

Tim Hutton
21st August 2001 move on to variant 1 >>

1. Squirm3 Science

The squirm3 world is a simple one based on an artificial chemistry. Molecules of different types (colours) drift around. Molecules of type 'e' are red, those of 'f' are green. Molecules 'a', 'b', 'c' and 'd' are orange, gray, cyan and blue respectively. Molecules also have state (a number from 0 to 3) but these aren't displayed.

Some molecules have bonds between them that limit their movement.

a. Squirm3 Physics - Molecule movement

Each molecule looks at which of the surrounding eight squares it can move to (if any) and picks one at random. A square is a valid move if:

b. Squirm3 Chemistry - Reactions

A reaction in the artificial chemistry of squirm3 creates or destroys bonds. A reaction is a local event, caused only by the right molecules being in the right place at the right time. A reaction can change the state of the molecules involved, as well as making or breaking bonds between them.

Here are the first two reactions, together they are sufficient to duplicate a string of genetic information such as e1-a1-b1-f1 as we will see afterwards. Any string composed of a sequence of a's, b's, c's and d's with an 'e' at one end and an 'f' at the other will replicate itself.
Reaction R1:
e1   e0        e2 - e3
|        =>    |  
x1             x1
A molecule of type 'e' is in state 1 (hence e1) and has a bond with a molecule of type 'x' (any type) also in state 1 (x1). Next to e1 is an unconnected molecule e0 (type 'e' in state 0). When this situation occurs, the reaction shown happens. The molecule e1 changes to state 2 (becoming e2), while the e0 molecule changes to state 3. A bond is created between the two 'e' molecules. R1 is responsible for starting the chain of duplication.

Reaction R2:
y2 - z3           y2 - z3
|          =>     |    | 
x1   x0           x2 - x3
The letters x,y,z are variables standing for any of the valid types. For R2 to occur, a molecule in state 1 (x1) must be next to a molecule of the same type in state 0 (x0). Also, x1 must be connected to (have a bond with) a y2, which in turn must be bonded to a z3, which must be next to the x0. R2 ensures that the genetic information is duplicated, since the free molecule x0 must be of the matching type for this reaction to occur.

This is how the replication sequence might proceed:

e1   e0        e2 - e3            e2 - e3             e2 - e3           e2 - e3
|              |                  |    |              |    |            |    |
a1      R1     a1          R2     a2 - a3     R2      a2 - a3     R2    a2 - a3
|       =>     |    a0     =>     |           =>      |    |      =>    |    |
b1             b1                 b1     b0           b2 - b3           b2 - b3
|              |                  |                   |                 |    |
f1             f1                 f1                  f1    f0          f2 - f3
Note that the process relies on free molecules (e0, a0, b0, f0) being in the right place and thus is typically quite slow.

For replication to repeat, the two strings need to split. Reactions R3 and R4 permit this.

Reaction R3:
x2 - y3         x1   y1
|    |     =>   |    |
f2 - f3         f1   f1
R3 lets the bottom of the string-pair split. Note that this can only happen when the whole string has been duplicated, ending with the final 'f' molecule.

Reaction R4:
x2 - z3         x1   z1
|    |     =>   |    |
y1   w1         y1   w1
The split continues up the string-pair, returning the two halves to state 1.

Here is an example of the splitting in action:

e2 - e3          e2 - e3          e2 - e3          e1   e1 
|    |           |    |           |    |           |    |           
a2 - a3    R3    a2 - a3    R4    a1   a1    R4    a1   a1   
|    |     =>    |    |     =>    |    |     =>    |    |  
b2 - b3          b1   b1          b1   b1          b1   b1   
|    |           |    |           |    |           |    |    
f2 - f3          f1   f1          f1   f1          f1   f1
These reactions can happen immediately after each other, the strings very quickly unzip themselves.

Other reactions

Reactions R1-R4 give a chemistry in which self-replicators are possible. If there were two types of string in the world then the one that reproduced faster would tend to be more populous since there is competition for resources. The Flood (see below) makes sure that only the fittest creatures survive - this is natural selection.

The other mechanism for evolution to occur is variability, the next three rules allow for this.

Reaction R5:
x2 - w3         x2 - w3
|          =>     \ 
y1 - z1        y0  z1
This reaction occurs only with low probability, P(R5). If R5 occurs, the gene y1 is lost from the replicating sequence. Typically this will give a string that replicates at a quicker rate but it may remove essential functionality.

Reaction R6:
x2 - w3          x2 - w3
|          =>      \ 
y1   z0        y1 - z1
Reaction R6 also happens with low probability, P(R6). If R6 happens, the free molecule z0 is incorporated into the gene string, lengthening it. This will typically slow down the replication rate of this string but may add unexpected functionality.

Reaction R7:
x2 - w3          x2 - w3
|          =>    |    |
y1   z0          y2 - z3
Again, R7 only happens with low probability, P(R7). If R7 happens, the free molecule z0 is copied into the gene string even though it may not match its pair, y1.

2. The Flood

Every 10,000 time steps a cataclysm occurs that wipes out one half of the area, to make sure that strings that aren't competitive get cleared away. The area removed alternates between left and right each time, just to be sure that only those strings that replicate well are kept. The empty space is filled with raw material (unconnected molecules of state 0 with random type) - this lets the replication continue.

3. Results

If you let Squirm3 run for 100,000 time steps or so, it will become clear that the selection pressures favour shorter strings - most of the survivors are the shortest possible self-replicator e1-f1 (red-green).

We have demonstrated several things, the strings are:

What we would like to demonstrate:

Did I say get in touch already? Get in touch!