So I developed an addiction to
artificial intelligence
and I would like to show you this package
I created for
unity called Genetic Switch.
This is an implementation of a genetic algorithm,
a program inspired by the Darwin's theory of evolution.
Meet Bob.
Bob is a sheep.
It has four legs one head and a lot of wool ...
At a molecular level this information
is stored in the DNA.
We could cut this DNA in small parts,
and call each part a gene.
Each gene is responsible for the data
of one specific aspect of Bob.
In my system this will be stored as a bit array,
a serie of 0 & 1.
Without transparency we store this color
with 24 bits.
8 bits for the red channel, 8 for
green channel and 8 for the blue channel.
This data is then converted into an
actual color via a specific component
called a "Phenom",
a physical expression of a gene.
Now Bob meet Sarah, another sheep
with another DNA.
If Bob and Sarah have a baby,
this child's DNA will be the result
of a crossover between Bob's and Sarah's
DNA.
Finally a small chance of mutation
is taken in account.
Things start to get funky when we start to add
natural selection in the process.
As only sheep that did not die will reproduce only
some gene will be passed to the next
generation
and this is a simulation that showcase it.
In this simulation the selection process act in two times
and is based on the color I can select here.
First a wolf will eat some of the sheep.
The wolf have a chance to eat any sheep
but have troubles to see the colors near the selected one.
Second, once a generation passed the wolf,
remaining sheep have a chance to reproduce.
In this case they are sorted by
fitness to selected color.
Sheep with best fitness reproduce first
this kinda mimics the charisma of a sheep.
When enough children has been created this way
the old generation dies to age and
the new one passes the wolf.
Notice how first generation
include many different colors.
Now let's fast forward
and see what happen after few generations.
After 30 generations, most sheep are
greenish or very close to green.
Due to mutation chance there is still from time
other colors but they will usually
be eaten by wolf.
Now because mutation keep a small variety of colors
we could try to change target color and see
if population still adapt.
Here is the lucky mutation ...
As we started with a very few diversity
it takes more time to get there
but we start to see some very good
wool colors.
After 50 generations
sheep population evolved in favor
to red color.
I hope
you enjoy this simple demo of that library.
It's all set up for more complex
simulations and I hope to share
with you some more soon. See ya !
