Basic simulation of natural selection
A study of the evolution of artificial life in varied environments
LOVE EKSTAM LJUSEGREN, MIKAEL FLORÉN
Degree Project in Computer Science, DD143X Supervisor: Roberto Bresin
Examiner: Örjan Ekeberg
Abstract
In this project one way of simulating natural selection and
its most basic principles was examined. In order to show
how simple and effective evolutionary systems really can be,
a number of simulated lifeforms struggled for survival and
evolved over generations. With this project we wanted both
to showcase simple evolutionary principles for educational
purposes and to highlight the potential of self improving al-
gorithms. This has been done by posing two questions. Can
this type of simple simulation suffice to produce stable popu-
lation and gene pools, given time? And if so, can it evolve to
different stable solutions given different problems, in this case
environments, to tackle? The test setup was very simple; a
set of simulated organisms were placed in different environ-
ments, with the ability to produce offspring with random
mutations. The results of the simulation show that the pop-
ulation stabilizes in both numbers and gene configurations
over time. It also shows that different environmental con-
ditions lead to different gene configurations. From this we
can conclude that a basic test environment such as the one
described in this project can be used for producing both dif-
ferent and stable species that are far better suited to survive
than early generations.
Sammanfattning
I det här projektet undersöktes ett sätt att simulera natur- ligt urval med sina mest grundläggande principer. För att visa hur simpla och kraftfulla evolutionära system kan va- ra, kämpade ett antal simulerade livsformer för överlevnad och utvecklades över generationer. Med detta projekt ville vi både påvisa hur enkla evolutionära system kan vara för ut- bildningsändamål, och visa potentialen hos självförbättrande algoritmer. Detta gjordes genom att ställa två frågor. Kan ett enkelt system, så som det som beskrivs i denna rapport, räcka för att producera stabila populationer och genpooler, givet tid? Och om så är fallet, kan de utvecklas till olika stabila lösningar givet olika problem, i detta fall olika mil- jöer, att ta itu med? Testmiljön var väldigt enkel; ett antal simulerade livsformer, med förmågan att producera avkom- ma med slumpmässiga mutationer, placerades i olika miljöer.
Resultaten från simulationen visar att vi efter en tid får po- pulationer som är stabila i både genuppsättning och antal.
De visar också att olika miljöer leder till olika genuppsätt-
ningar. Från detta kan vi dra slutsatsen att ett så simpelt
test som detta, kan användas för att producera både olika
och stabila arter som är bättre anpassade för att överleva än
tidiga generationer.
Contents
1 Introduction 1
2 Problem statement 1
2.1 Scope . . . . 1
3 Background 2 3.1 Terminology . . . . 2
3.2 Existing Techniques . . . . 3
3.2.1 Parameter-based . . . . 3
3.2.2 Module-based . . . . 3
3.2.3 Neural net-based . . . . 3
3.2.4 Choice of technique . . . . 3
4 Method 4 4.1 Blob model . . . . 4
4.1.1 Gene model . . . . 4
4.1.2 Behaviour . . . . 5
4.2 Environment model . . . . 6
4.3 User Interaction . . . . 6
4.4 Visualization . . . . 6
4.5 Test Setup . . . . 7
5 Results 9 5.1 Population and gene convergence over time . . . . 9
5.2 Gene distribution per room . . . 12
6 Discussion 14 6.1 Can blobs converge to certain gene configurations and population numbers over time? . . . 14
6.2 Can different conditions give rise to different species? . . . 14
6.3 Additional results . . . 15
6.4 Conclusions . . . 15
Appendices 17 A Tables 17 A.1 Population averages over time periods . . . 17
A.2 Gene averages over time periods . . . 17
1 Introduction
This project treats the subject of simulation of evolution through natural selection. Specif- ically, we try to show that evolution occurs even with a very basic model of artificial life.
The goal is to do this in a way that is very clear and easy to understand, but that keeps the evolutionary power of creating complex organisms.
This area of research is interesting for multiple reasons. For one, it can be used for educational purposes to demonstrate how evolution might happen in the real world. From the point of view of biologists, this type of tool can be used to help predict real-world occurrences. On the other hand, this type of self-improving system may also be useful in the context of artificial intelligence and learning systems, as well as optimizing certain np-complete problems.
Most cutting edge evolutionary simulations are very mathematically focused and show mod- ern evolutionary modelling. This project instead strives to showcase the bare principles of evolution by natural selection with a strong focus on individuals and their genes. This is accomplished by simulating groups of individuals with a gene-centered approach, as suggested by Richard Dawkins (2006) in “The Selfish Gene”, that allows us to track the origin and “life”
of any gene.
2 Problem statement
The main questions examined are:
• Can blobs converge to certain gene configurations and population numbers over time?
• Can different environmental conditions give rise to different species?
2.1 Scope
This project is not in any way striving to describe the way evolution by natural selection work in actual existing species. Neither does it try to replicate any details of how selection works or has worked in real life.
Instead, the intent is to use the basic theory and principles of natural selection to show that
even with simple rules, evolutionary patterns can emerge from random changes. It also sets
out to show that such rules can give a very strong competitive edge to certain groups of
individuals, given enough time.
3 Background
Evolution by natural selection is a concept that was first introduced by Darwin (1859) in his book “On the origin of species”. Since it was first conceived the theory has been changed and refined to a large degree, the discovery of DNA for example was a huge game changer, but the core of the theory has only grown stronger.
It describes the process in which certain traits become more or less common within a species without outside intervention. The name natural selection was chosen because of the parallel to artificial selection(selective breeding), which was a known technique since long before the theory of evolution. The theory says that individuals with a certain characteristic that is beneficial (in the sense that it helps with survival and/or reproduction) will become more common over time as compared to those without that particular characteristic. This means that such beneficial mutations will accumulate over time, since offspring are likely to share features with it parents. This is a process that can completely change, or give rise to entirely new, species over generations.
Dawkins (2006) popularized the idea of gene centered evolution. Previously it was common to think that the selection process worked at the level of individuals or groups. What gene centered evolution means is that the selection really takes place at the genetic level. It might manifest through competitive and less competitive groups and individuals, but the core of the evolution takes place by competition between rival genetic codes. This is the view that this project is modelled after and the most popular one in recent times.
3.1 Terminology
Natural selection is one of the most basic principles of evolution. A few assumptions are made: traits vary between individuals, those traits affect the ability or opportunity to reproduce, and the traits are in some way hereditary. Given these conditions, some traits will prove superior over time, causing them to be more common than the less effective ones.
Allele is the name for any one of the alternate forms of a gene. For example, say that the human eye colour is controlled by one gene. Then there will be one allele that makes it blue and one that makes it brown etc. (Malats and Calafell, 2003)
Genotype: “The genotype of an organism is the class to which that organism belongs as determined by the description of the actual physical material made up of DNA that was passed to the organism by its parents at the organism’s conception” (Lewontin, 2011)
Phenotype: “The phenotype of an organism is the class to which that organism belongs as
determined by the description of the physical and behavioural characteristics of the organism,
for example its size and shape, its metabolic activities and its pattern of movement” (Lewontin,
2011)
3.2 Existing Techniques
There are various ways to simulate artificial life and the evolution thereof. The choice of method depends on the goal of the simulation. Adamatzky and Komosinski (2005) describes some common techniques, which are summarized below.
3.2.1 Parameter-based
This approach is relatively simple. A creature’s traits are represented by some number of physical characteristics (e.g. speed and size). These directly define the way the creature looks and behaves, as well as its other physical characteristics. That is to say, this model is a pure phenotype one, the only inheritance is of the exact traits of the parents. An offspring could in a simple example of this model inherit the speed of the mother and the size of the father and a random mutation would act directly on a physical characteristic.
3.2.2 Module-based
In this approach, which is used in this project, creatures are defined by modules similar to alleles or collections of alleles. Each module affects one or more characteristics of the creature and there may be several such modules that affect the same characteristic. In essence, a module may represent some set of alleles, and inheritance would occur on a module level (an offspring would inherit several modules from the mother and the father). Mutations might appear as the addition or removal of a given module or a change in the significance a module has for the creatures development of characteristics. This model, in other words support the genotype/phenotype distinction. So there may be, for example, several types of module combinations that give the exact same physical properties.
3.2.3 Neural net-based
This type of approach focuses more on the ability of individuals to learn from experience. Thus it is well suited for more complex and intelligent organisms, but poorly suited for simulating natural selection over extended time periods. The method itself is relatively complex, and requires more processing time as the neural net would have to be updated throughout the creature’s lifetime.
3.2.4 Choice of technique
This project is constructed using a module based approach with strength factors assigned to
each gene. One major advantage of this model is to allow for a strong genotype-phenotype
distinction. This makes it possible to obtain more information about the origin of a given
species, such as differentiating between two species with similar characteristics but different
genetic composition. Another major advantage is that it is very easy to represent both gene compositions and changes over time as numerical values, so that clear results can be reached.
4 Method
The basis of this project is a visual simulation of basic natural selection in which blobs strive for survival in an artificial environment. Blobs are able to produce clones that inherit genes from the “parent”, with possible mutations providing variation. The simulation runs over the course of many generations and every generation will differ slightly from the last, with individuals with more suitable genes getting a survivability advantage and possibly more offspring. Time is measured in discrete time steps, with any update events occurring once per time step.
To perform the simulations an application written in C++
1was used. The details of how the simulation works, including how blobs interacts with the environment and their genes, are described in the following chapter, as are specifics of their implementation.
4.1 Blob model
A blob is a simple creature, with only a few variables defining its traits and behaviour.
The most central concept to the survival of the blob is its energy level. The blob can gain energy by eating food, while various activities reduce the energy level. The blob’s energy drains over time, with the rate dependent on the size, speed, and metabolism of the blob.
Reproduction also requires an energy investment, and won’t be attempted unless a certain energy threshold is met. If a blob reaches an energy level of zero, it dies of starvation.
A blob can also die of old age, which occurs after 1000 time steps. This imposes an additional evolutionary pressure; merely getting enough food to survive is not enough let a certain combination of alleles survive over time.
Reproduction occurs asexually. A blob can, given enough energy, produce offspring. The offspring inherits the alleles of its parent, with 10% chance for each allele to increase or decrease its strength factor by one. The offspring blob’s survival and reproductive qualities will therefore be dependent on that of its forefathers, allowing better traits to be naturally selected over time. Asexual reproduction provides the advantage that the models needs very little behavioural code or guidance, which in turn allows for results to be more reliable, with less human interference.
4.1.1 Gene model
As mentioned, genes are modelled using modules. Each module affects one or more charac- teristics of a blob, as described in each individual module.
1Source code available at https://github.com/Stormfish/Silverfish
Rather than modelling a large number of similar modules, a strength factor was assigned to each module, and let each specific strength of a module represent an allele. A higher value increases the effect of the given module. This roughly corresponds to how a larger number of alleles working in concert would give more prominent effects in mammals.
Inheritance in this model is fairly simple. The strength value for a gene in the offspring is set to the corresponding value of its parent. n addition to this, every module in the offspring has a 10% chance to mutate in strength, which either increases or decreases the value of that gene by 1. This gives us a source of entropy in the genetic codes and allowing new genetic variations to occur.
The set of modules used is as follows:
• Size:
– “Camel” gene: Each point increases energy by 50% and size by 20%, and reduces speed by 30%
– “Chubby” gene: Each point increases size by 50% and energy by 20%, and reduces speed by 40%
• Speed:
– Leg size: Each point increases speed by 40% and reduces energy by 40%
– Hyperactivity: Each point increases speed and energy consumption by 50%
This particular set of modules was selected for two main reasons. First, the set of genes must be small, so that results and patterns can be presented clearly in a short amount of time.
Second, the set must allow blobs to evolve in multiple, clear ways, enabling notably different phenotypes.
4.1.2 Behaviour
The behaviour of a blob is quite simplistic. Their movement is random; in each time step a random direction is chosen, and the blob moves a distance based on their speed in that direction. In other words, there is no self-preservation built into the blob’s behaviour, and they do not actively seek out food.
If a blob collides with a food object while at less than maximum energy, it eats that piece of food, increasing its energy.
Procreation occurs whenever the blob reaches its maximum energy. When this happens, the
parent uses 25% of its energy to spawn an offspring with 20% of its energy, resulting in a net
loss of energy. As described in the above section on the gene model, the offspring will have a
similar, but possibly mutated, set of genes.
4.2 Environment model
The blobs exist within an environment made up of different rooms. The rooms can have arbitrary positions in the world space, and may or may not be connected to other rooms.
This allows the creation of isolated systems within the same world, which can be compared to each other. Each room is of a rectangular shape, but the height and width can vary between rooms.
Other than size and position, the amount of food in a room can also vary based on a user parameter. Every room grows food that the blobs can eat to gain energy and stay alive. Food is inserted randomly throughout the room every time step (with the amount determined by the parameters of the room), up to a limit based on the size of the room.
The blobs can move between adjacent rooms by moving across the connecting edge. If there is no other room on the other side of an edge, the blob instead collides with the edge, remaining inside that room.
4.3 User Interaction
The user should have limited ability to affect a simulation in progress. In order to obtain useful results however, some interaction is enabled. In our application, most of this interaction takes the form of configuration before starting the actual simulation. This includes both defining the environment (and all its parameters, as defined above), as well as allowing customization of the initial blob population.
When the simulation is active, interaction is more limited. Users are simply allowed to change the speed of the simulation, or to pause it entirely to examine the current state further.
There is also a command to print the current state of the simulation to a log file. The log file is written in a CSV (comma-separated values) format, which can be processed by various other programs.
4.4 Visualization
For the visualization, the SDL
2library is used. The blobs are represented by green squares, and the food is represented by yellow dots. The blobs are rendered with a size proportional to the size mentioned in the blob model, making it possible to see the trends in the size of the blobs.
2Simple DirectMedia Layer http://www.libsdl.org/