A.I. Learns to Play Hill Climb Racing

In this AI video ...

Hey guys, how’s it going? Long time no see, I guess it has been a while. That’s my bad. Anyway, enough apologies. Let’s get into the video Over the past month I’ve been building a clone of the game Hillclimb racing. It turned out to be a pretty simple game I actually didn’t really have any hassles with it. I mean, it’s really just a car driving on a hill. I mean what could be difficult about that? So yeah, that was a thing. If you somehow missed that then check out my videos documenting the very scientific approach I used to build the game. Anyway time to do what you guys are all here for. Time to AI the shit out of it I’m gonna be using neat for this problem. Neat stands for neural Neat stands for neural evolution of augmented topologies. You can click here to check out a video explaining it Which I haven’t made yet, but when I do I’ll put it right up there So if you’re from the future feel free to click that if not then I don’t know Google it. Neat is basically a super sexy way of combining neural networks with the genetic algorithm We’re gonna be slapping that on some cars so they can learn how to drive too easy But before I do that, I’m gonna add some final touches. Give the game a little bit of flair a little bit of magic a little bit of Are you ready? Is that what I think it is? No way no Fucking why holy shit Evan you have done yourself this time It’s fucking grass. Oh Yeah, so grass that probably took me a little longer than I’m willing to admit are you impressed enough yet? Can I can I go home now are we done? No? You didn’t come here for grass fine. Okay, we’re that done the only thing left to do is add a few lines of code Which we’ll add neat to the game I Can’t feel you Okay, you beauty she is ready. This is the moment we’ve all been waiting for over two months in the making and here we Go so the first channel. Oh my No No Yeah That didn’t go so well There are a few minor things that can probably improve on here. We go. This one should work and away we go Really silly car where are your wheels? You fool Okay enough digging around I forget sometimes that I’m not like a failed compilation video like a one-man failed compilation Oh that that describes me a little too well Oh, I got a little too real all right moving on after blood sweat tears and fucking grass Finally got it working. I’m not not not not pulling you like this time. I actually got it working. I actually did the thing all right Here we go there 150 cars in each generation this program uses the genetic algorithm which is basically survival of the fittest if a car does well Then it’s selected to be able to breed so that it’s offspring survives to the next generation just like normal evolution at first The cars have no idea what they’re doing something going forward full speed some of them chucking it in reverse But a few of them not many just a couple figure out that they need to go forward without flipping over Well, they don’t quite get it yet, but they get mad as As the generations go on the drivers slowly learn how to navigate the landscape the weird grafting in the top right corner is the neural network Controlling the leading car. That’s why it changes when the leader’s overtaken this brain structure is actually what’s Evolving over the generations now to talk about the inputs to the neural network This is basically what the car sees if the neural network is the brain the inputs are what is perceived from the senses You can see these inputs on the left hand side of the neural network So the car knows the angle of the car whether or not touching the ground It’s angular velocity how far it is off the ground and the gradient of the ground in front of it So basically whether it’s going uphill or downhill the neural network uses these values to figure out what to do next The outputs are just the controls for the cars they’re just forward and backwards The changes subtle but you might notice the terrain is getting more and more difficult the further the cars get This is because you don’t want to chuck the cars in the deep end because they’ll learn nothing Instead you want to first train the cars on flat out easier ground so they can figure out how to go forward and not fall over and stuff Before chucking them into the really steep and difficult terrain This is known as incremental learning at least I think it is that’s what I call it so deal with it It’s basically the concept of learn to walk before you can run or don’t teach a baby Shakespeare A cute little touch that I’ve added which I doubt anyone actually noticed is that the driver’s shirts are actually genetic This means that the color of a player’s shirt will be passed down through generation So at the start of the players had random colored shirts but as time goes on those players who do better have more children And thus their colored shirt becomes more prominent This is why all the shirts become green in no time at all I don’t know I thought it was cool cute little touch but if you don’t care then I don’t blame you Wait I’m I’m positive here did you see that I think this is my favorite shot in the entire thing You have car after car struggling to make it up the hill giving everything they can to Samat the insurmountable and then you have one final car remaining There’s no one around all eyes on him or hope is in this one car and as he slowly topples down to his demise You pan back to his mate just hanging out giving zero fuck you want to move mate You want to give him a hand bloody useless what how did you get here? How are you there? Why aren’t you driving? What are you doing anyway as you were? See I’m gonna skip to generation 14 because nothing really happens up until then The insurmountable hill has finally been conquered and shortly he will continue his triumphant conquer and he’s dead Generation 16 we finally get even further and this time for sure he will continue to any step So our own generation 17 and we should be pretty close to the end of the map by now There’s not much further to go so hopefully it’s only a few more generations And it’s got a little slower isn’t it? Oh no don’t you do this don’t you fucking do this Oh Fuck Fuck oh not not I’m done I’m done I’m out I’m good day you’re home Okay okay All right so clearly something broke I think I was pushing my computer a little hard Running a fears extension is actually a pretty computationally heavy task So potentially running 150 of those was not my greatest move So what to do I could always reduce the population size down a bit But then they won’t learn anything you need almost a critical mass of players before they’ll actually start learning The solution was actually pretty obvious once I thought about it We need a large population size without having to run a large amount of players at a single time So what if we split the population up into groups and run each of those groups individually This is known as batch learning it obviously takes a lot longer because for each generation We need to run the simulation multiple times but I think it’s worth it I also took this opportunity to increase the population size a little bit Before we had 150 players so I decided up a little bit to say 750 But then there is only 50 players at any given time so it should run a lot smoother Everything else works the same once all the groups are finished the players which did the best I’ve chosen to pass their genes down to the next generation Standard shit Oh Oh Oh Oh Oh Oh You You You Know it’s a different map, but we’re already almost up to the same point we got to last time so yeah It’s significant improvement having a much larger population size is a huge advantage because it allows the neat algorithm to better Emulate evolution in nature because in nature It’s rare to have a population size less than a few hundred thousand never mind less than 200 and we have done it by Generation four they have reached the end of the map Holy shit, we did it. God. This has been a long project Remember those grass and chop right corner which seemed to magically control the cars if you want to learn how these magical neural networks work Taking build projects like this one then you should check out brilliant dog pro tip. It’s it’s not magic It’s actually math and computer science Brain dog has interactive lessons on neural networks which give you all the tools you need to build your own Your networks might seem like a bit of a daunting task But they break it down into small chunks which is super easy to understand and unlike me They actually take the time to go into the details you need to understand it Not just label others black magic and move on the first 200 people to use the link brilliant dog slash code bullet We’ll get 20% off in annual subscription So if you want to learn how to summon magic graphs and also split this channel at the same time So I can make more of this content then I would really appreciate it if you’d go check them out. Woo Alright, thanks for watching. Thank you for the people who’ve been with me the entire time It’s been on hell of a ride I’m pretty keen to move on to the next project because this has been like months at this point Sorry, this did take so long University’s getting hectic and I went to New Zealand for a bit It was sorry I just really didn’t have enough time to spend on code bullet stuff Speaking of uni, we’re getting to the really really ugly end of the semester So to inform you that I’m gonna have to take some time off code bullet I finished on like the 20th of this month so it’s only like a week or two But yeah, I have to spend some time focusing on uni because that is that is still important But after that we’ll be on summer vacation which means I will have three to four months of time to spend just doing code bullet stuff Which I’m actually really excited about I’ve never had a decent amount of time to focus just on code bullet stuff There’s always been university or been sick or going away On the like 20th of 21st I’ll probably put out an announcement video Just heads up to see what you guys can expect for the next few months What my plans are that kind of thing anyway. Thank you for watching Sorry this outro has been a bit long been ramming a little bit. See you around!

AI video(s) you might be interested in …