Square Genes, a Life Simulator

Below is an artificial life simulator. It has rules about space, energy and gene expressions. But it has no rules about fitness or survival.

Some lucky genes happen to copy before its nucleus ages and dies. But it will need energy to do so, or die of starvation. Only those that make it, can populate this virtual world.

It is an experiment following my previous post on bottom up design verifying that where self-copying is possible, when it appears, it will self-select and evolve.

What are you seeing? Yellow is a nucleus with a set of genes. Green is a part that can harvest energy from the environment, but slowly. Red can eat green and yellow as food. Blue can eat Red.

When there are empty areas, the simulator will spawn nuclei with random genes and a bit of energy. It usually takes around 50.000 spawns for the first viable gene to appear. But the simulation is fast enough to enjoy the spectacle that follows.

You can click a square and see its genes and how they express.

The Genetic Code

The genes instruct the entity what to do. Genes can instruct to build a part. Or to create a seedling nucleus with a certain level of mutation. Or point at where to build parts. Or check certain signals and decide to express or not.

The genetic code is a list of pairs, a command and a level. A gene starts and ends with a begin code ( - ).

PART? point up/right/down/left, if there is no part there, stop expressing this gene

point up/right/down/left, if there is no part there, stop expressing this gene ENERGY? if energy is below 1/4, half, 3/4, or full, stop expressing

if energy is below 1/4, half, 3/4, or full, stop expressing AGE? if age is not old/halfway/young/new, stop

if age is not old/halfway/young/new, stop LEVEL? if nucleus is not the first/second/third/fourth, stop

if nucleus is not the first/second/third/fourth, stop ROTATE rotate where up is, or mirror left/right

rotate where up is, or mirror left/right BUILD if possible, build where this gene is pointing (using PART )

if possible, build where this gene is pointing (using ) SEED mutate genes, how much depends on the level, and build a nucleus

The simulation as shown here is somewhat small, to conserve CPU and work on mobile. You can run a much larger version or check out the source on github.