9.9: Genetic Algorithm: Interactive Selection – The Nature of Code

9.9: Genetic Algorithm: Interactive Selection – The Nature of Code


Hello, welcome to another genetic
algorithms’ video.. boy I seem to be making a lot of these genetic
algorithm’s videos recently this is.. in this video I’m going to
explore something called interactive selection. The idea is a lot of ideas behind
interactive selection pioneered by Karl Sims, here is a reference to an artwork a
project created in 1997 the museum exhibit. You can look kind of here at
this image and what you see in this image are a lot of screens and these
screens are displaying images and then you see along the floor here all these
sensors. So a viewer at this museum exhibit would come and stand in front of
an image and when the viewer is standing in front of the image and looking at the image they’re standing on the sens.. sensor and
some type of counter some type of algorithmic system is keeping track of
how long the viewer is standing on top of that sensor. Why is all this happening? Ok so I’ve said
before when I’ve talked about using a genetic algorithm in a project I’ve said there
are two main things that are really up to you to design that your sort creative
input into what’s going to happen in your project, one is this idea of a
genotype vs phenotype which is also a really sort of key factor in the
Karl Sims project that I’m showing to you and the thing that I’m going to
demonstrate and make for you as well but really what am talking about right
now is this fitness function. The reason why I’ve come over here on
the whiteboard to kind of write that down is usually the next stop from here is what is the math formula for the fitness?
Well it’s you know inverse distance squared divided by the amount of time it
took to do this and the blah blah blah blah you’re coming up with some kind of
number of characters correct blah blah.. some type of actual mathematical function.
Well in this case there is nothing other than the amount of time of a viewer spent
looking at a particular image so in this case it’s the behavior of the
visitor to the exhibit that is driving the fitness function and you can think
of this as a lot of other ways you can have a rating system you know the fitness of a particular
piece of music is the amount of star ratings it got on some you know music
sharing web service type of thing so user input into the fitness user driven
design, right? You could be saying I want to design a
particular a pattern for a dress but instead of hand making that design I’m
going to just have a program algorithmically generated
hundred designs I’m going to look at them pick the ones
I like and generate a hundred new designs. So you could evolve where you are
essentially the designer assigning fitness of the things in the
evolutionary system and that’s what’s happening here in this particular
exhibit. So how would you do that? But, this is
really all I have to say this video is really more about this idea and actually
this.. it becomes there’s so many possibilities; do I write a web application
or do I create something with computer vision and perhaps I can explore, if you
have some suggestions, some particular scenarios but I have for you just to
look at some code and see an example happening I have perhaps what might be the lamest
version of interactive selection ever and I’m going to show you this example
and talk you through the code a little bit. So this is the example right here and
what it has that you can see if i zoom in here is a bunch of different designs
for faces and as you can see as I hover my mouse over them I’m incrementing a number. So i’m saying
here like this I really really like this particular face design so I have these designs, I have about I
think there’s ten of them, here; one two three four five six seven eight nine ten
and I’ve given them all a rating and then I have a button here that i can
press evolve next generation and I click that button and you can see I now
have a new generation of designs from the ones that got a high rating and I can say
you know what I love purple let’s give this one a high rating but
the size of this one is pretty good let’s hit evolve and you can see I’ve got
a lot of purple ones now so again and I could keep hitting evolve
and you can see there’s some mutation at play and things happening I’m not suggesting to you that there’s
anything particularly revolutionary about this but it is showing you
the basic mechanics of this system so let me.. let me..
let’s.. let’s.. let’s think about how this works number one is I’m using some form of
interaction like a roll over to increment the fitness value for a
particular face and then uh and and then then I also have this idea of a
design so there’s also this question here of… [laughs] there was nothing
written there. There’s also this question here of
genotype vs phenotype so in Karl Sims’ example, if you read the
paper that I have linked in this video’s description, there’s an elaborate discussion of how
the images in the exhibition are created out of these kind of like mathematical
formula sequences written in a programming language Lisp and all sorts
of craziness like that but what I’m actually doing in my particular example
which is quite a technique that you can apply is I actually have a a DNA the
DNA is actually just a sequence of floating-point numbers and each floating
point number is between 0 and 1 so that is the signature for the design and if I
go you can see we have this idea of genotype and phenotype if I look at the
code very briefly in dna.js you can see this is the genotype right here
this is the data; an array of genes everything with a random number between
0 and 1 and then the expression of that data is in the face object and the face
object right here you can see that expression happening here so this face object has a lot of parts
of its design. It has a size.. a radius an eye x and y position, the size
of the eyes, an eye color, a mouth color the mouth position, the mouth width, the
mouth height and all of those things are taking these numbers between 0 and 1 and
mapping them into some other range like a color between 0 and 255 or a position
between 25 and 60 that type of thing. So this is a one way of taking this idea
of data and then mapping it to a bunch of variables which then draw this kind
of ridiculous design of a face with a couple rectangles so I think that you as a person watching
this video probably could come up with a much more creative or beautiful or
interesting type of design perhaps you can think of it as like a
vector-based shape of paths or you could think of other ways of
encoding your design maybe it’s a piece of music so it’s
not actually even a visual design it’s a sequence of notes and rhythms but whatever that is then you just need
a rating system and in this case I just have this rollover function that
whenever the user is rolling over that particular object the fitness is going
up by some small amount pretty arbitrary but you could have a drop down menu to
assign rating but one of the things I think is kind of key to realize about
this kind of system so if I go back to show you just really really briefly if I
would go back to this Shakespeare example, right? The Shakespeare example look at this
in the time I talked there I evolved a hundred seventy five
generations each population having 200 elements. Let
me run this example for you again and there’s ten elements in the
population and I’m clicking around oh and I’m gonna have to.. I’ve got to actually
rate some and I got eight generations with 10 elements so the scale here is a bit of a problem
while with this kind of numeric fitness function of mathematical calculation I
could just be churning churning out generation after generation after
generation after generation over and over again but here I’ve got a look at
it, I’ve got to evaluate it, I’ve got to think about it, I’ve got to roll over it then I’ve got to
click the button so scale is an issue but one thing you might think about is the
web the network a distributed network of
viewers.. could you create some type of system maybe you could have a website by the way that has a different design,
this is kind of an awful idea, but you know you have a website where
you want somebody to buy something or think of something besides buy, you just
want someone to download a nice flower image because that’s going to make the
world a better place what if you showed a different design
each time somebody came to the website and the sort of rating of that design
was how likely whether or not that person got to sort of some end result of
using the website. You can think of this as it kind’s of ties into this idea of reinforcement
learning but you could evolve a particular design through users kind of
unconscious behavior of just kind of using a particular website whether it’s
intuitive or not or playing a game. There’s lots of possibilities besides
just rating but the point is if you have something up on the web you can have a
lot of people rating and evolving all at the same time with like a centralized
database. Anyway I’m rambling on and on and on
in this video and you could find this code link to in the description of the video
I hope that you maybe try to make your own evolutionary design system with
interactive selection and share it with me and so we can see what kind of new and
creative ideas and maybe if you share some with me I’ll come back and make a
video where I show some of them so that you guys can see what other people have
been making. Ok see you soon in another video soon. I’ve got one more genetic
algorithm video at least coming in the pipeline here that’ll be after
this one in the playlist. Ok, goodbye. Subtitles by the Amara.org community

21 thoughts on “9.9: Genetic Algorithm: Interactive Selection – The Nature of Code”

  1. I hope you know that those videos are listed under your GA playlist altough they are marked as unlisted.. #BugOrFeature

  2. Nice video. Inspirered by this topic(saw it before in the Kadenze course) i made a p5.js program to make nice flowers (i am Dutch so we make our own flowers). https://github.com/Lebo124/Flowersystem At the moment i am trying translating this program in Processing and maybe make an Android app of it.

  3. I'd like to see imperative style Lisps used once more for graphics programming. Looks like the original was written in an extension of Common Lisp they called *Lisp. Another great video by the way!

  4. It would be interesting to see if an array of 100 x 100 pixels with random colours could be evolved into what the user might experience as "cute" or "angry" and see what the end result gives after a couple of generations

  5. MAN, YOU ARE AWESOME!

    yes, i am shouthing. but because I AM SO FREAKING HAPPY!!!
    DID I SAY THAT YOU ARE AWESOME???

    YOU ARE!!!!

    just thank you for sharing a lot of your tutorial, explanation and everything. YOU ARE AWESOOMMMMEEEEEEEEE!!!!!

    p.s. you are awesome.

  6. I did a p5.js version of this Face selection but my head get's white after the first click and after time everything is white… 🙁

  7. Interactive selection would probably be great when applying genetic algorithms in game development. I'm currently having my college thesis in computer science and this series is a LOT of help. Thanks!

  8. for the exmple u gave at the start rl looks much better sens it can keep track of what works and change the picture evry frame u can than run an evolutionary algorithm on that deep rl

  9. u can use a learning encoder which was traind on the type of data u want and then just tweek the input to get the output u want

Leave a Reply

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