Inteligência Artificial jogando Flappy Bird!!

1.72M views990 WordsCopy TextShare
Universo Programado
Seja muito bem vindo ao Universo Programado! Neste vídeo você verá como a Inteligência Artificial ap...
Video Transcript:
THIS IS SPARTA Welcome to another video of Universo Programado And this time the AI will play FlappyBird And if you like this kind of content don't forget to subscribe to receive new videos when they're out! For those who don't know FlappyBird was a mobile game that became really popular in 2014 You played as a bird jumping through obstacles To do that you could only jump The objective is to get as far as possible In FlappyBird I used the same algorithm of the Dinosaur's video So if you'd like to know how this algorithm works Check that video out, I've explained everything there I've used the same algorithm because it's really efficient for this situation where the agent has to dodge obstacles. When making FlappyBird I already knew that the AI would play with ease.
For the AI it's easier than the Google's Dinosaur Because the speed remains the same It has only one action which is jump and need less information to play but I didn't know that it would be so easy Because they didn't even need to train: The first random individuals were able to play the game indefinitely And now we will see how this is possible. FlappyBird is a prime example for us to visualize how a neural network works since the game is so simple and a small neural network is already able to play the game and because it's so small we can visualize it graphically and understand what's happening inside (of their brain) The first step is to decide which informations that the AI needs to play If you're in doubt of which informations it needs Just think of human player playing All information that the human player needs to play the AI will need it too. The AI will work much better if you hand them distances because distances does not depend of the position It doesn't matter if the pipe is too low or too high.
What really matters is the distance of the bird to the center of the pipes When making the charts the horizontal distance will be X axis the vertical distance will be Y axis and the final result determining if the bird will or wont jump will be the Z axis So we will be able to visualize the neural network graphically Using a 3 dimensional graph Now we have to discover what is the biggest value that the horizontal distance can get In this case, 1100 in a situation like this: and also we have to find out the lowest value. That would be a situation like this: -75 Then we do the same thing for the vertical distance so now we have our graph. Each point in this rectangle is a different situation that the AI can be Now what we need to know is which of this points are bigger than zero so the bird jumps and which of this points are equal to 0 so the bird won't jump Each bird of the population will be one of this functions that were randomly created.
But the game is so simple and the neural network is so small it happens that one of the bird is already "BOIRNE" prepared to play the game It's already *BOIRNE* with the right behaviour to where to jump and where not to jump In which situation it jumps and in the ones that it won't And to facilitate the visualization of the graph I will paint all the points that are bigger than 0 in blue And leave all the points equal to 0 in green we will see the graph from above. Now we can really see the neural network for what really is: A function This graph on the right contains all the possible situations that the AI may encounter the red dot being its current situation The green dots are situations that it shouldn't jump the blue dots are situations that it should jump Check that as it approaches the pipe the horizontal distance lowers So the red dot which is its current situation goes toward the point zero which is this black dot When it goes through the pipe it starts receiving the informations of the next pipe This is why the red dot appears to be teleporting It's already in another situation Gravity is always pulling them down to the situations in blue but when they are in a blue situation it jumps and goes back to the green situation Its objective is to keep to the green situation But in this channel the AI can't simply win so easily What do we have to do? You've guessed it: Make them miserable In order to do that I made the canes move and also made a special obstacle that they can only pass using the parachute.
This cane is too narrow so you can't just jump through it The only way the AI could pass through it is using the parachute and saving the parachute for this obstacle Just like in the Google's Dinosaur video the parachute recharges every 4000 pixels of distance and the special cane appears every 5000 pixels So now I will make my thang and let it train when the AI is good I will return DO IT! JUST DO IT! Don't let your dreams be dreams!
After a few generations they got this score and they won't die The AI already learned how to react to all obstacles in all speeds Sadly they won this time. I tried to make as hard as I could Even then it learned and there's infinity. .
. It learned how to play. That's all folks!
If you're still here don't forget to leave your like and share with your friends because it helps the channel to grow It's amazing to know that you're interested in programming and AI Thank you for your attention and until the next one!
Copyright © 2024. Made with ♥ in London by YTScribe.com