Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

camouflage evolution simulator

Post any examples or modules that you want to share here

camouflage evolution simulator

Postby KG_is_back » 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).
Attachments
color_matcher.fsm
(1.6 KiB) Downloaded 1390 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: camouflage evolution simulator

Postby Tronic » Tue May 17, 2016 7:35 pm

Intriguing...
Setting the environment, with gray color,
with sexual reproduction active,
seem that the mutation occurs in a more explicit way, or is my assumption?
The color environment, affect the trend of the mutation?
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: camouflage evolution simulator

Postby KG_is_back » Tue May 17, 2016 8:11 pm

There is a minor flaw in the code that I didn't bother to fix, because it does not affect the functionality.
In case of sexual reproduction, it picks 3 random members, breeds the best two and replaces the third with the offspring. However, it actually puts the offspring in a place of first individual in population with identical genome to the third excluded one. Because of this, in case of sexual reproduction the mutations seem to propagate from top to down sometimes...
I decided to keep it, because it gives better idea about the proportions.

Tronic wrote:The color environment, affect the trend of the mutation?


It doesn't. However, this simulation also demonstrates punctuated equilibrium - closer the organism is to optimal state, less likely it is for mutation to introduce improvement instead of degradation. Result is, that instantly after the change in environment rate of change sky-rockets and slows down as organisms approach optimum.

Also keep in mind that not all mutations cause the same amount of change. Since the genome is binary number, change in upper digits is more significant than in lower digits.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: camouflage evolution simulator

Postby KG_is_back » Tue May 17, 2016 9:50 pm

New version:
Now organisms have limited breeding-range (specified as parameter), meaning they can breed only with organisms close nearby. Also number of sexes is now a parameter. More specifically, all organisms are hermaphrodites, but the parameter selects how many individuals are needed to produce offspring, each contributing by 1/N part of his genome.
Population size is now also a parameter (map size squared).
Note that map is handled as torus - top side is connected with bottom and left is connected with right, like in asteroids game.


New observations:
With geographical distribution playing the role, now it is possible to observe how new genes/alleles/mutations spread in population. For example, start with completely black population (set environment black and wait until all organisms adapt perfectly). Set low mutation rate (around 100 works good) and no. of sexes to 2. Now switch environment to white. You can observe, that new genes spawn at single location and spread radially, eventually overlapping, creating interesting pattern.
This is the reason why humans have "races". Originally uniform population spread over entire globe. At each place people developed different mutations which geographically "radiate" form single location, like when mould grows. The transitions form one race to other is smooth and race within on itself is not genetically uniform. Because of this the term race is no longer considered scientific and grown out of use, because it does not describe reality at all.
Attachments
color_matcher_2.fsm
(1.92 KiB) Downloaded 1360 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: camouflage evolution simulator

Postby tektoog » Fri Apr 24, 2020 4:44 am

Hey, very nice project! :D ;)
Would it be possible to extract the generated grid color as an array?
Even better, would it be possible to save the generated color grid as a jpeg, or any image format, and then reload the file in a way that it has to match the source grid to... unlock a synth for example? ;) :P :D
Like some kind of barcode or captchaThingy...? Don't know if this would be really effective in the real world?
Any thoughts?
"Essential random order for chaotic repetitive sequences"
User avatar
tektoog
 
Posts: 141
Joined: Sat Oct 30, 2010 11:49 pm
Location: Geneva - Switzerland


Return to User Examples

Who is online

Users browsing this forum: Google [Bot] and 62 guests