9.10: Genetic Algorithm: Continuous Evolutionary System – The Nature of Code

Hello and welcome to one more video
about genetic algorithms. This probably won’t be my last video
ever about genetic algorithms because I do have some more in my head that I’m
planning to do at some point but this does kind of wrap up a bunch of the
range of ideas that I’ve been talking about in this series of videos that you
may or may not have been watching so far but I want to talk about sort of a
fundamental flaw in the examples that I’ve been showing to you so this is the Smart Rockets example that
I built as a coding challenge kind of playing out and what these rockets are
doing is they’re evolving a kind of path from the bottom of the screen to this
target and they have this DNA built into them which is a lot of vectors, forces to
kind of push them around the screen and overtime they’re trying to get around this
obstacle and make their way and if you run this for a while
eventually they’ll get there but let’s think about how this system works as
compared to the real world that you and I live in. So let’s say these aren’t smart rockets
but they are monkeys and these monkeys are evolving. Its.. the scenario that
we have here is kind of like okay let’s have 100 monkeys all born at once then
let those 100 monkeys live for exactly 200 frames of animation then all 100 of
those monkeys immediately have 100 children and die and then the next 100
monkeys live for 200 frames then they all at exactly the same time all die
but have 100 children first so this idea of this sort of cycle of
generations of a generation all growing up exactly together then the next
generation growing up exactly together doesn’t really mirror the way that a
fluid system, a continuous system, like our actual natural biological world
works. So something that you might think about
for a creative project, if you’re doing a fish tank stimulation or some type of
other type of simulation of kind of creative imaginary creatures living in
an ecosystem; is how much you create an evolutionary system that is continuous
and I have an example of that for you I’m not going to build it from scratch
here and and this is a system of bloops and this is actually been running for a
while and then each bloop.., I’m calling the bloops; being this circle.
I’m saying bloop as if you know what I bloop is, I don’t even know what a bloop is but let’s talk about this. So here’s how
this system works there is this idea of a bloop and it is
represented on the screen as a circle and each bloop has DNA and the DNA is an
array but it’s actually.. I’m making you a very very simplistic version of
something that you could adapt expand on and that DNA has a single number between
0 and 1 in it so a single floating point number so
here might be a bloop that has a number 0.1, there might be a bloop that has a number
0.5, there might be a bloop that has number 0.9. This one might to look like this this one might look like this and this
one might look like this. So the DNA it’s a single property is mapped to its
size smaller medium big from 0 to 1 but it’s not just back to its size it’s also
mapped to its speed so the smaller it is the faster it can move the larger it is
the slower it moves and I’m going to come back over to the program and you
can see this has been evolving for a time and you can see the kind of like
magic here is that what the system evolves to is like medium sized
objects but I’m gonna refresh this and you can see at the beginning there’s a lot of little things squirting
or moving all around the screen really fast and there’s big ones kind of moving
around the screen rather slowly. You can see they’re fading out. So the difference
here is that these bloops just live out a life they have a timer built into them and if I
look at the bloop object, right? There is a bloop object and it has as part of its..
as part of its (properties) a variable a health parameter. That health parameter just
counts down. There happens to be food.. there happens to be food
around the screen so here’s the thing something that small
is able to move around the screen very very quickly but because it’s small it’s
less likely to bump into the food something that’s big moves around kind
of slowly so it’s less likely to find the food but if the food is anywhere
near it’s going to likely bump into it. Medium kind of moves medium speed with
a medium size and so this system tends to optimize towards medium objects; objects that can move
with some speed and are big enough to by accident find the objects and the emotion here is
not that interesting it’s just kind of random wandering perlin-noisy type of motion
but what you’ll see the sort of key factor here is that when an object dies
it fades away and it’s gone. How does the genetic information get
passed from one generation to another I don’t just put in a hundred have them
all live have a score at the end and they just each one as it’s living out its life we can see there is
a function in the bloop object called this.reproduce and what.. I’m gonna just
delete some of the comments here so we can look at this more easily; what this reproduce does is it just
every single frame of animation it picks a random number and if that random
number happens to be less than 0.000 0.0005 then a child is born so this mirrors more closely of course
it’s not exactly like our biological world but something that lives a longer
period of time has more chances to perhaps find a partner to mate with to
pass genetic information down to the next generation now in this case these bloop objects are
just cloning a version of themselves there’s no.. there’s no two coming together
to cross over genetic information it just makes a copy with mutation but
so the longer it lives the more likely it is to make a copy of itself so we can see here as.. if I run it again
you can see these little tiny one speeding around the screen they’re just gonna fade out without
having a lot of chances to reproduce, the big ones are going to kind of fade out
without having a lot of chances to reproduce but the medium sized ones are
going to last for quite a while. Some other strange artifacts happen actually when one of these objects dies it leaves
a piece of food right there so sometimes you can have a cluster of the
big objects all sort dying and leaving food and then like kind of eating the leftovers
so that some sort of interesting things can kind of happen even
in this like really really basic simulation but I think the
things for you to think about are what might be a system like this where the
rules that govern the motion of these objects are more interesting? You could
go back and look at some of my video tutorials about steering behaviours. How.. what might be other rules that
govern the way things find food or move around our escape predators in an
ecosystem simulation. What might be a system where instead of
just every frame of animation there’s a small chance an object
might make a copy of itself. What about every time to objects come within a
certain distance there’s a chance that they might perform crossover and
mutation to make a new sort of child object. So there’s a lot of possible ways
you know.. what.. can you have.. can you make an object with more than
just a single property, what about its design could you see
different colors being passed down from generation to generation certain color
taking over? So there’s all sorts of I think
possibilities in working out a system like this. So this system it has
crossover and mutation, it has genotype and phenotype; the thing
that it doesn’t really have is a fitness function. There is no fitness assigned to any of
these objects.Fitness is just something.. it’s not survival of the fittest
here it’s survival of the survivors. The
things that survived longer have a more likely chance of passing their genetic
information around to the next.. down to the next generation. Ok so I’m sure you have questions about
this, ideas about this, please write them in the comments and uh you know I’d love
to see if you make something from this or create an interesting idea out of this
and I will perhaps do a follow up video if there are some new ideas that come
out of this particular one of some new techniques and things that I can
demonstrate for you. Okay thanks for watching. Oh and the code;
[laughs] the code is.. you’ll find it in the description of this video too. Okay goodbye. Subtitles by the Amara.org community


Add a Comment

Your email address will not be published. Required fields are marked *