camouflage evolution simulator
Posted: Tue May 17, 2016 6:25 pm
Just a quick project that I find interesting. A simple schematic simulating evolution of camouflage in animals.
Each organism has a genome consisting of 24bits which are directly translated into RGB colour.
Each tick it picks 2 (or 3 in case of sexual reproduction) organisms (displayed as colourful rectangles) sorts them by how much they deviate from the colour of the environment (outline of the display), then breeds the most fit ones and puts the offspring in the place of least fit one (effectively killing it).
There is a chance the offspring receives a mutation (one bit in genome flips) - the reciprocal of the mutation-rate can be edited (100 = one in a hundred chance to get mutant). Population size is fixed to 1600.
Comparison of which organism is closer to a colour is done by calculating square deviation:
sd=(red - environment_red)^2 + (green - environment_green)^2 + (blue - environment_blue)^2
You can control various parameters:
"Reset to random" generates population of random organisms.
"run simulation" is basically a pause button.
"reproductions per tick" controls the speed of the simulation.
"environment color" is the color the organisms are expected to match.
"sex/asex" switches between sexual and asexual reproduction.
"mutation rate 1/n" sets the reciprocal mutation rate. Higher values = lower chance of mutation.
My observations:
Sexual reproduction seems to be highly superior to asexual. Asexual organisms rely on new mutations to occur in their offspring to improve their survivability, while sexual organisms can combine mutations from multiple organisms. This is consistent with what we see in nature - asexually reproducing organisms tend to have over 300times higher mutation rate. Not because they are "less evolved" but because they require higher mutation rate to evolve. Sexually reproducing organisms can evolve fast even with lower mutation rates, due to reasons explained above.
It is also interesting that each colour effectively serves as a separate gene. When blue organism adapts to red environment I noticed two possible scenarios. Either it first looses "blue" gene, becoming black as a transitional phase before evolving "red" gene, or it first evolves "red" gene, becoming temporarily magenta. Usually both versions are present at the same time (transition from red suited population to blue suited population is a mix of black and magenta organisms).
Each organism has a genome consisting of 24bits which are directly translated into RGB colour.
Each tick it picks 2 (or 3 in case of sexual reproduction) organisms (displayed as colourful rectangles) sorts them by how much they deviate from the colour of the environment (outline of the display), then breeds the most fit ones and puts the offspring in the place of least fit one (effectively killing it).
There is a chance the offspring receives a mutation (one bit in genome flips) - the reciprocal of the mutation-rate can be edited (100 = one in a hundred chance to get mutant). Population size is fixed to 1600.
Comparison of which organism is closer to a colour is done by calculating square deviation:
sd=(red - environment_red)^2 + (green - environment_green)^2 + (blue - environment_blue)^2
You can control various parameters:
"Reset to random" generates population of random organisms.
"run simulation" is basically a pause button.
"reproductions per tick" controls the speed of the simulation.
"environment color" is the color the organisms are expected to match.
"sex/asex" switches between sexual and asexual reproduction.
"mutation rate 1/n" sets the reciprocal mutation rate. Higher values = lower chance of mutation.
My observations:
Sexual reproduction seems to be highly superior to asexual. Asexual organisms rely on new mutations to occur in their offspring to improve their survivability, while sexual organisms can combine mutations from multiple organisms. This is consistent with what we see in nature - asexually reproducing organisms tend to have over 300times higher mutation rate. Not because they are "less evolved" but because they require higher mutation rate to evolve. Sexually reproducing organisms can evolve fast even with lower mutation rates, due to reasons explained above.
It is also interesting that each colour effectively serves as a separate gene. When blue organism adapts to red environment I noticed two possible scenarios. Either it first looses "blue" gene, becoming black as a transitional phase before evolving "red" gene, or it first evolves "red" gene, becoming temporarily magenta. Usually both versions are present at the same time (transition from red suited population to blue suited population is a mix of black and magenta organisms).