Main

I evolved cats to hunt burgers! (My attempt to implement a genetic algorithm)

I wanted to try neural networks and genetic algorithms, so I made a simulation/game in which there are some cats and they must evolve to become the ultimate burger hunters. ##################################################################### External links: This cat does not exist: https://thiscatdoesnotexist.com/ How does the cat website work?: https://www.lyrn.ai/2018/12/26/a-style-based-generator-architecture-for-generative-adversarial-networks/ Source code download: https://github.com/Vejimart/alife1 https://drive.google.com/file/d/1QcvEPzPAHllqDSCACgsM2owMIG-coa9g/view?usp=sharing ##################################################################### Music from https://www.zapsplat.com Funky Walk Disco Streets Music from YouTube Audio Library Cover - Patrick Patrikios

Cyberawesome labs

2 years ago

a few years ago i learned about a very interesting kind of algorithm genetic algorithms tell me if that doesn't sound fancy those things caught my attention and i knew i had to try them myself anyway how do they work to understand them let's quickly go over the phenomenon that inspired them biological evolution here's a living thing that living thing either lives long enough to make more of itself or it dies before being capable of doing so this is what we know as natural selection in the proces
s of making more of their own some things won't be copied exactly 100 as they originally were this is what we know as mutation mutations will sometimes help new creatures stay alive some other times it will make it harder for them to stay alive and some other times they may not be immediately relevant the lesson here is that things that follow this loop of overcoming some kind of selection and then making inaccurate copies of themselves will tend to generate things that get better at being selec
ted over time so how do we do all of this with a computer first things first we need some kind of environment for our creatures to live in i decided to go for a simple game in which there will be some cats and their goal is to eat as many burgers as they can at the beginning cats will spawn with a certain amount of energy and they will lose it as time goes on luckily for them energy can be replenished by moving to a border and aiding it in order to change their position cats will have the abilit
y to move forwards or backwards as well as rotating in either direction moving and rotating will cause them additional energy so they won't be able to get away with just wandering around in hopes of finding a tasty burger in their path if they fail to eat enough burgers their energy will drop to zero and they will be removed this is how they will be selected by the way this artificial selection or fitness evaluation is what separates genetic algorithms from being just a loop of making random gue
sses and crossing your fingers expecting some of it to be good if a cat is good enough at hunting borders it will accumulate energy and once it goes over a set energy threshold it will split creating a new cat in the process this will cost some energy as well but at that point the parent cat will have more than enough so it won't be a problem for him i already described what will happen when cats move and eat rugers but i still haven't told you how they will know where to move every cat will be
controlled by a small neural network you can think of it as the brain of the cat it will take information about the environment and the cat's position as inputs then perform some mathematical operations to those numbers and finally generate a pair of numbers that will tell the cat how fast to move and rotate at the beginning our population of cats will have networks with only a few initial connections made at random whenever a cat splits the new cat's brain will be based on its parents brain but
it won't be a perfect copy some intentional mutations will be made at random so its behavior will also be different and just as it happens with biological evolution mutations that result in a better burger hunter will help it survive and get selected for further replication i want to make a pause so we can appreciate what just happened we will not tell the cats how to find burgers but even we have all these things in place some burger eating cats will sooner or later evolve without further inpu
t or outside interaction i don't know about you but to me that's quite amazing now that we have a plan it's time to actually make the thing [Music] [Music] [Music] it was at this point that i got bored of staring at yellow and blue circles all day long so i decided to finally turn them into cats and burgers to aid myself in that task i made another python script to download 2 000 cap pictures from my website that generates them at random as a matter of fact it does so by using neural networks as
well but they are trained instead of evolved i'll leave some links to that website and an explanation of how it works at the video description [Music] i also added a leaderboard to make it look more like a competition it will show the cats that have eaten the greatest number of burgers in the past 3 minutes as well as how much energy they have left how long they have been alive how complex their brain is in terms of intermediate notes and connections and how many ancestors they have it helped m
e verify that evolution was actually happening and thanks to it i discovered some ugly bugs i hadn't noticed before without further ado we can finally watch some cats evolving yeah they are pretty bad right now but things will start to get interesting in a few moments in the meantime it's a good time to tell you a couple more things i think it's important to make it clear that these cats can't learn to become better than they were when they first appeared there are other techniques that allow fo
r that but i focused solely on evolution this means that any single cat won't improve its performance but the population as a whole will get better at hunting burgers over time another interesting thing here that i didn't initially consider is that there's another challenge in addition to hunting borders since food is limited they also compete against each other not only do they have to be good enough to find burgers they also have to outperform other cats finally i also made them gain some ener
gy by just being next to a burger that way they can get a partial reward even if they don't manage to eat it i consider this would be useful during the first minutes of the game when some cats may be somewhat attracted to burgers without being good hunters yet as this gives them a chance to not die instantly this will take a while so i'll just fast forward near the end so we can see what happens once it's done [Music] after five hours of evolution we can see cats have developed a patrolling stra
tegy in which they move in circles until they detect a burger nearby and then they move towards it to be honest i was expecting the cats to evolve a more interesting strategy than just moving around in circles but every time i run the game they evolve pretty much the same way i guess it's just a good way of not starving to that so good for them i guess now that you made it this far i want to thank you for spending your time watching this video i have been wanting to make something like this for
a while now it was a lot of fun and i'm glad i could finally do it you can find a link to download the source code in the description it's written in python so you'll need to have that installed in order to run it feel free to download it and use it as you wish before ending the video i have a final request for you consider leaving a comment and subscribing to this channel that feedback will help me figure out what kind of content you will enjoy the most so i can make better and more interesting
stuff in the future i'm open to any and all suggestions challenges and feedback so feel free to write whatever is on your mind that's all i have to say for now and i don't quite know how to end the video so i'll just leave you for a couple of seconds with this nightmarish low resolution picture that the random cat website throwed at me [Music] bye

Comments

@victorvelazquez9696

Salúdame prro :D Grate video bro, I think you made it fun and interesting for someone that isn't really into this kind of things. Grate job! :)

@tuyyoconecta2

Amazing!!! You explained it in a simple and fun way. Keep doing it!

@SarahDSay

¡Excelente contenido! Fácil de entender, muy ilustrativo y sobre todo muy interesante. Realmente me agrada la idea de que tengas más contenido similar. ¡Gran trabajo! 👏✨

@alanjimenez5788

Saludame prro x2 :D Excelente trabajo y con muy buena explicación, no conocía mucho acerca del tema solo lo básico que llegue a ver en algún vídeo, fue bastante entretenido e interesante.

@andresjimenez873

Que buena explicación y que forma tan interesante de ponerla con gatitos. Muy buen vídeo. :)

@rebecajimenezporras4223

Felicidades! Muy interesante tu proyecto 😉

@LuisHongo

Awesome experiment

@juliajimenez817

Muy interesante 😊