AI learns to play PACMAN using NEAT
In this AI video ...
Get that trash out of here! Who would want to watch that garbage? This is YouTube! You guys aren’t here to read, especially when you’ve got such a talented artist as your host. Hey guys, it’s Evan from Code Bullet here. You probably met my writing before, but as great as White Text on a Black background is I thought it would be about time to upgrade. I know it’s a bit early to start, thank you for my Patreon supporters, but I can’t help it. Thank you guys so much, thanks to you all for being able to go out by this awesome mic and start actually talking in my videos for once. Anyway, it is Christmas, ladies and gentlemen. Mostly gentlemen, actually 95% gentlemen, just made myself sad. So yes, it’s Pac-Man time, let me tell you about the struggle which is the making of Pac-Man and why it took me so long to make, sorry about the wait guys. First of all, Pac-Man is hard, it’s way more complicated of a game than you think. Compared to other games like the Asteroids where the AI only had to learn to point and shoot and also avoid, Pac-Man is so much more complicated. So when I just threw the AI in it, it had no idea what it was doing, it wasn’t learning anything. I didn’t know when to eat the ghosts, when to not eat the ghosts, sometimes it was a lager, sometimes it wasn’t, and it also had to learn to navigate the maze at the same time. It was a mess, it was not happening, so I had to hold its hand a little bit. I split the learning into three stages. The first stage was with no ghosts, no big dots, just Pac-Man learning to navigate the maze. The only way it could die is if it stops moving or doesn’t eat any pellets within a certain amount of time. After about 20 generations of learning, we introduced the ghosts, but we keep the big dots out of there. Now that Pac-Man has learned to navigate the maze, it can focus on learning how to evolve to avoid the ghosts. And since there are no big dots, Pac-Man isn’t confused by sometimes being able to eat them and sometimes they kill him. Then after another 40 generations of learning, we introduced the big dots and we can finally finish the game in theory. In practice, it’s always a bit different, but that’s the idea. I’m sorry about my drawing skills, but I need to put something on the screen. I know my amazing artistic skills might be distracting for some, but I’m sure you guys can bear with it. Alright, let’s jump into it. When the A.O. is a first thrown into the game, they are useless. They absolutely suck. The best first generation could do is an A.I. which always turns right, which is fantastic unless you intend on playing the game of Pac-Man. So safe to say, that didn’t last very long. By generation 2, it has figured out how to turn, both left and right, which is great, but it still gets stuck. I hope you’re enjoying the new layout. It’s got the new on that controlling the Pac-Man in the bottom right corner, so you can watch it evolve as Pac-Man’s behavior involved. I think it’s pretty cool. As you can imagine, playing Pac-Man without any ghosts is quite simple. Well, it’s simple for a human, but surprisingly hard for an A.I. So I had to change the controls up to make it far more intuitive for them. Instead of the controls turning Pac-Man in an absolute direction, like North, South, East, or West, like they normally are, I had to change it so it’s relative to Pac-Man. So for example, turn left or right. This way they could have simple rules such as when Pac-Man sees a wall in front of it, it turns left. You can see how complicated the neural network is getting even though we haven’t added any ghosts or any big dots yet. OK, so by generation 18, it’s getting pretty good. It still actually doesn’t complete the maze, but it gets up to around 200, which I’m pretty happy with. As you’d expect, the A.I.s have no idea what’s going on. They’ve just been suddenly introduced to evil ghosts which will try and eat them. So fair to say they’re not doing super well. It’s kind of like introducing an invasive species. It’s evolve or perish, but slowly and surely the A.I.s learn to avoid the ghosts. Also, I hope you noticed the awesome sprites I made for Pac-Man and the ghosts. Well, I’ll be honest, I just copied Pac-Man, but I’ve had original designs for the ghosts. I got an angry blinky, a girl pinky, which is all the personality she gets. Clyde is just uselessly adorable and I kind of lost interest by the time I made a dinky, so he’s just kind of like angry with a smile. Pac-Man is actually a very difficult game without the big dots, without the energizer dots, even for a human. The fact that these guys are getting scores of about 150 is fairly impressive, I think. So I’m fairly happy with that. Let’s add the dots and see how they go. They actually adapt very quickly to the introduction of the big dots, and as you would expect, the scores they are getting skyrocket. This guy is just going to town on the ghosts, getting some revenge for the past 40 generations of torture. Here we are at Generation 73 and Spoiler Alert. This is the one that finally does it. Finally after two weeks of trying and failing of blood, sweat and tears, finally got it to finish the game. There’s no way I can make a video and have it not finish the game. So I got four dots left, get the button to, get the top two, and then get confused and dies. Hey guys, I hope you appreciated the mic. A bunch of people are asking for it, which is why I did it. And I think it’s a lot more fun than just white text on a black background. But if you guys prefer that, tell me in the comments. And if you guys prefer me with a microphone, also tell me in the comments. It’s really appreciated. I know I already thanked them, but I want to send another huge thanks to my Patreon, but really allowing me to do this. I’m still being a pain in the ass and hasn’t actually approved my channel yet, which is kind of frustrating, but thanks to my Patreon, I can actually keep out. While I’m thanking people, I would like to thank my buddies over at my Discord channel who helped me make the awesome intro of the start. I say help me make, they did everything. I added some music to it. It’s awesome. Thank you guys so much. One topic of outsourcing my work to you guys. My channel art is trash. It is not going to cut it. You guys have seen my attempted art at a fair to say, but I need a better help. So if anyone wants to be a bloody champion and head over to my Discord channel to post any art there, that would be phenomenal. Thank you guys so much. I’ve decided to do live Q&As every week. I put it out to my Patreons and they reckon the best time for them was any day from 830 till 9. So I’m going to choose Sunday night, 830 till 9. That’s Australia and Eastern Standard time. So if you guys can make it, that would be awesome. Send me a question. I’ll try and answer as many people as I possibly can within that time. As per usual, I do have a beautiful fail video for you guys. I hope you enjoyed watching. I hope you enjoyed the fail video. Have a good one. See you next time.