Be very, very welcome to the channel My name is Victor Dias and you are watching Universo Programado In today's video, the AI will learn to do something that I don't even know- how to drive. Grab some popcorn and fasten your seatbelt because this is gonna be fast Are you serious? Are you really going to be doing these jokes until the end of the video?
What is the problem? Oh my god. Your jokes are terrible.
Feeling sassy huh? Go learn how to drive. Before we start, don't forget to subscribe to the channel and leave your like This is critical for me to keep making these videos.
If you would like more information about how this algorithm works, I recommend you watch my last two videos. First Dinosaur and then Flappy Bird. Because in them I explain how the algorithm works and show you why artificial intelligence is sensational!
The links are in the description. So let's go. The first thing you have to do is pick a track.
I chose this one. Look how cool it is. After we have to create the collision matrix.
It's what indicates where the car may or may not ride. Only in the elements that we put the value equal to one- Is that the car will be able to drive. Now we have to fill it.
So we will go through the whole image, checking which pixels are gray If the pixel is gray, it's because it's part of the track. And if it's part of the track the car can drive So we put value one in the collision matrix Anything other than gray, we set to zero And this is the result. Each point is a possible position that the car can occupy Now that we have mapped the track, we need to think of a way to send this information to the neural network, the car needs to somehow collect this information.
An interesting way I found was to install twelve sensors around the car. Each sensor will measure the distance from the car to the nearest wall in that direction. This distance is measured in pixels, and then we'll send it to the neural network.
In addition to distance, I am also sending speed. So that the AI knows at what speed it is and with that be able to execute more accurate movements. In the end, the algorithm will decide what action it will take.
Depending on the sensor configuration at that time. From there we just let the natural selection act and select the best car. But there is still a problem: How will the algorithm know which car is the best?
Because we know the best car is the one that managed to get closer to the finish line. But we cannot use Euclidean distance as the criterion. Because this will happen: When calculating the distance of a straight line, the green dot is closer to the finish line than the blue dot If we use this kind of distance, the algorithm will not work.
Because cars that never moved will be considered better than those that have moved away from the finish line So to solve this, I'll use another algorithm to map the distances on the track Its name is Wavefront Algorithm and there is a video of him here on the channel called ''Algoritimo Térmico'' which shows a little bit about its behavior. The thermal algorithm is very simple. We will need another matrix to map these distances.
At the finish line we set a zero because it has zero distance to itself. And from there we start to propagate this distance always increasing a value in the neighboring units. After the algorithm is finished, the matrix will look something like this.
So here is the zero of the finish line It will increase according to the distance from point zero. These -1, means they are off-track points and should not be calculated Each point now has the value of its distance to the finish line Now we can evaluate the cars the right way Because now the car that stops at the green dot will be considered worse than the car that stops at the blue dot But the problems are not over, even after that this can happen. .
. As car behavior is partially random. .
. it may happen that they stand still or go around in circles. So they won't hit, and if they don't hit the generation never ends and the algorithm can't go on.
To solve this we can even add a timer, but this is not a good solution I preferred to create a laser that will move and destroy the cars as it goes. So enough talk and let's see the network learning to drive. Remember that during the race the weights of the neural network never change, only the inputs will change because they depend on the sensors, and as the car is moving the sensors are always changing the value.
LET'S GO! *celebration sounds* Hey! I managed to learn, now what?
And now what? Ran out of arguments? You don't even know what an argument is.
I still drive better than you. Oh my dear. My brain has eighty-six billion neurons, yours at most has twenty Put your little weights down.
Okay, let's wait for a few more years. Hmm hmm, don't hold your breath. Since you're so good, may I make it harder?
Of course you can! So, I'll add some obstacles and I'll be back in 3,2,1. Ok, so I added some obstacles.
Those that are spinning the car can't touch I added a turbo zone, if the car goes over it accelerates and I added a mud zone if the car goes over it will slow down I changed the track a bit, and now the laser accelerates over time As the track got harder, I had to put more sensors in the car's front. So I decided to take all the sensors that were behind the car and placed them in the front. Because the car almost never backed up, so they were unnecessary The idea now is that the natural selection of the cars, prioritize the cars that pass through the turbo and discard the cars that pass through the mud.
Because cars that pass through the mud will be destroyed by the laser. I'll accelerate the beginning a little bit, when it's better I'll be back. One thing that strikes me a lot about I.
A is its accuracy, it can get into that narrow part at an impressive speed. Hey! I also would like to give my opinion.
Okay darling, you can talk. Getting in there is not difficult. I don't depend on my eyes or fingers to perform my movements.
My reflexes are instantaneous, the information comes to me in an exact and pure way. If my network is calibrated right, getting in there is the smallest of problems The hard part is when I need to act differently to- -very similar situations. Ok ok, thanks for explaining how you work, but now focus on your goal.
Now that the AI learned how to run the track, let's take a closer look at the moves it makes. Finally we will see how the sensors behave near the collision matrix. And for today that's it guys!
If you liked- Hey! Can I finish the video this time? Yes you can.
Thanks! You human being for watching me! If you enjoyed seeing me driving, give a like so my cousin here on YouTube will recommend the video to everyone I will be famous in the A.
I family! Thanks my pardner!