CellLife
This is an attempt to simulate evolution. In the applet below simple creatures
fight for survival. Those that do survive have their genes copied into
a new creature. Mutation causes the design of the creatures to occasionally
change. Natural selection causes those designs that are more successful
to drive out the inferior ones.
The rules couldn't be simpler:
-
red cells eat green and pink cells, otherwise cells bounce off each other
-
when a creature loses its pink cell it dies
While that's running, have a read below.
Source:
The CellLife project is open source. The source files are here:
-
CellLife.java - The main applet source file,
stores a list of tjhCreature's.
-
tjhCreature.java - This class manages the
properties of a creature, stores a singe tjhCell - the root cell.
-
tjhCell.java - This class manages the properties
of a single cell. Each cell has a list of sub-cells, creating a tree structure.
-
tjhGene.java - The genome representation of
the design of a creature. Each gene contains the type of the cell it represents.
This is another tree structure, mirroring the physical aspect of the creature
(its phenotype).
-
tjhNeuron.java - Each cell can respond to
nearby cells by moving in some way, this is a model of a simple neuron.
-
tjh2dVector.java - A utility class that
manages a 2D location or vector.
-
tjhBucket.java - The structure for each square
in our space-partitioning system, stores a flag saying whether the square
has a cell in it and a reference to the cell if there is one.
-
tjhBuckets.java - The time-saving space-partitioning
class that detects collisions between cells.
I've zipped up the source code into a single file for easier download:
CellLife.zip (all of 14KB!)
Have a look at the code documentation (generated
by javadoc) - see, it's not difficult is it?
To use the source code:
-
Copy the above files and this html file (index.html).
-
Download Sun's Java Development Kit (http://java.sun.com/products)
-
Compile with the command: javac *.java.
-
Load index.html into a java-supporting browser and enjoy.
To generate the documentation use the command: javadoc *.java -d
dox
This will create a separate directory dox for all the
html files (avoids overwriting this index.html for a start).
Some simple things to change to get you started:
-
Change MAX_CREATURES in CellLife.java to put
more creatures into the world.
-
Change RADIUS in tjhCell.java to make the cells
bigger or smaller.
-
Change P_PHYSICAL_MUTATION in tjhGene.java to
make physical mutations happen more or less often.
If you make some exciting changes or improvements to the code then duplicate
this page on your own site so we can all share your wisdom. The aim of
this project is to spark discussion, primarily on the Primordial Life mailing
list (see below).
Background:
There have been several attempts to simulate the evolutionary design process.
Here are just a couple:
-
Primordial Life - Colourful
2D biots take over the internet.
-
Framsticks - A physical 3D simulation
of stick-creatures that try to walk and swim.
Other links and information can be found at: http://alife.org.
None of the simulations I have seen even approach the sheer creativity
of evolution. There are several reasons for this, firstly that by its nature
evolution requires large populations and lots of time to work. More interestingly,
for an evolution simulation to really take off you need the right representation
not only to allow the creatures enough flexibility to create successful
forms but also with the right pressures to drive the survival of those
creatures that are more successful in interesting ways.
This simulation is an attempt to get at that representation. At the
moment all it shows is potential. It was thoroughly inspired by the Primordial
Life project but addresses two perceived issues:
-
it is in open-source Java on the web so everyone can play with it and explore
the possibilities.
-
it uses a tree-structure of cells to allow large modular creatures with
interacting limbs.
Desired improvements:
-
more intelligent control of cell movement
-
more inputs to each cell (eg. communication between cells, current orientation
of parent)
-
creature itself should be able to control its gross movement, not just
drift
Changes since 26/7/00:
-
Reproduction occurs only when two creatures bump their pink bits against
each other (or population is really small). Thanks to David Evans (see
below) for this suggestion.
CellLife was written by Tim J. Hutton (homepage,
email).
Details:
The design of the creatures is an attempt to get closer to a physical model
of real creatures interacting. It is not intended to be an accurate simulation
of biological multicellular organisms, it just borrows some of the ideas.
In an attempt to keep things simple, there are just two types of cell:
red and green. (Pink ones behave like greens, they are just drawn differently.)
The pink cells (the roots of the tree structure) are like the 'heart' of
the creature - the creature must protect its pink cell from attack else
die. Green cells are intended to be like passive energy collectors (plant
similarities) but are currently useless and rapidly get selected out. Red
cells are intended to be the active attackers, gathering food by eating
the green cells of other creatures and improving reproduction chances by
killing other creatures.
The creatures are made up of a tree of cells extending outwards from
the root cell. The branches of the tree move about at random unless the
creatures control this movement themselves by rotating themselves either
clockwise or anticlockwise around their parent.
The intention is that creatures will respond to their environment by
moving into a set position or in a set manner, allowing them to adopt various
positions (defensive, attacking, searching, etc.) depending on their mood.
The current implementation of the creatures' brains gives each of them
a single neuron. With the orientation defined by the cell's parent being
'behind' it, the cells responds to the presence of enemy cells to its left
or right. The neuron determines how the cells responds, if at all.
Sensory inputs: green_left, green_right, red_left, red_right
Possible outputs: rotate_left, rotate_right, no response
Edited highlights of the Primordial Life mailing list:
David Evans wrote (Thu, 27 Jul 2000 00:02:02 +0100):
What I thought might make an interesting evolutionary trade-off
is to base the reproduction on an explicit sexual pairing. I'm assuming
that at the moment when a biot dies, you replace it by spawning a new one
based on the genome of a randomly selected survivor in the pool. How about
if we created a new biot whenever the pink cells of two biots touched (at
the moment this relatively rare encounter does nothing but bounce.) Ideally,
the newborn would use a crossover-generated genome from both parents, but
it could also be randomly chosen from one or the other.
In a blind, hard-wired world I would expect to see some species
that flaunt their pink bits (they would lead short, but promiscuous lives)
and others that are more demure (leading long, boring lives.)
With vision and brains in gear, it should lead to interesting behaviour,
like defensive positions that open up into mating positions.
I realise that with the recent talk of wiring and brain boxes, that
the pink cell might be considered by some to be the brain, rather than
the genitals. I have, however, come across many life forms (mostly in middle-management)
where the two functions seem to have merged in the same organ.
Join the Primordial Life mailing list here!
Last modified: 16/2/01