🖥️ WRITING MY FIRST MACHINE LEARNING GAME! (1/4)

🖥️ WRITING MY FIRST MACHINE LEARNING GAME! (1/4)

November 17, 2019 100 By Stanley Isaacs


Today I have a very exciting episode for you all because as the title suggests It’s about machine learning But before we get into that I’d like to quickly share my history with machine learning so far Back when I was a kid I’ve always had an interest with AI I remember seeing the famous Karl Sims and all that procedurally generated genetic creatures using geometric shapes say that ten times fast and then train those creatures using a neural network This was the first time that I ever heard about neural networks, and I was instantly hooked but at the time I barely started learning algebra in school, so understanding how to write one was way out of my league fast forward to 2015 and Google released tensorflow which is a very very Convenient machine learning library made by some very smart people and one year later after that There is a flood of super cool machine learning demos all over the Internet and that is when I found myself Incredibly inspired to the point in which I knew I had to get my foot in the machine learning door But here’s the deal at the point of wanting to get serious with machine learning, I didn’t know calculus I hardly knew anything beyond basic geometry really But I knew if I really wanted to try and make some cool machine learning projects jumping straight into tensorflow without knowing the material Would’ve just meant all of my machine learning projects would have been the result of mastering the craft of copy and pasting code But I want to go out as no copy and paste master I wanted to go out as guy who knows how to write neural networks and apply them in cool ways so on March 17th 2017 I got serious and set out on a mission to learn how to write my own neural networks And I can proudly say six months later I successfully trained my first neural network completely from scratch. It was a super basic neural network I was able to learn the order of the super saiyan stages, but it was a major prideful moment for myself and today It’s finally time to start applying what I’ve learned and start writing some funky fresh machine learning projects Okay, so where do we begin? There is so much to cover with this project so buckle up everyone But I promise it is going to be a lot of fun Now I think a good place to start will be to tackle why even use machine learning AI to begin with so let’s first build a Simple game and start there. Here’s how our game works: We have a little running bot named Forrest who just felt like running. Forrest automatically runs straight But needs some help to turn left to right you see the only goal in this little robot life of his is to be able To run two complete laps on any course Touching the walls means failure for Forrest so with that said as of right now I have to help forest navigate the course using a joystick controller or else he won’t be able to run his desired two laps But wait, there’s a plot twist. I don’t want to help forrest navigate courses because I’m lazy I really just want to sit on my little tush and eat candy all day Why doesn’t forest navigate the course his own damn self? Well this is what happens when forest tries to do it on his own So we need to teach him how to complete this course on his own using some sort of artificial intelligence But before we add any AI let’s first take baby steps and give force the ability to control this controller Joystick now the joystick works like this if the joystick is tilted all the way to the right then the joystick will return a value of one if it’s tilt all the Way to the left That’s a value of negative one if centered zero and any percentage in between those three values is the percentage of that Value so halfway to the right is point five halfway to the left is negative 0.5 Simple maths you get it, but please do make a mental note that if I say tilt the joystick left to right This is what I mean by it right on right on So let’s give this controller the force tell them to just randomly guess how to tilt the joystick for now and let’s see what he? does Absolute dunce so So one simple AI we can give for us is some sort of path finding AI we place a bunch of markers on the course until forced to tilt the joystick left to right depending on where the next marker is in relation to him and 100% this will work, but it also comes with a few problems one with this solution He’ll only become the master of this one course and two I’ll still have to do a lot of work placing these markers for every new course and let me remind you guys I Am lazy So in complete surprise. We’re actually going to add a neural network based AI surprise No network someone the best solutions for this problem because not only will force be able to run the course on its own But if we train him right he’ll also learn a general rule for all Courses and be able to run laps around any course even ones that he’s never even been on Including this monsters boss battle of course here, but more on that later Oh, okay, so just to make sure we’re all still on the same page Here’s here’s where we’re at Forrest wants to be able to run two laps well in any course But currently only knows how to run forward. He needs help for me to navigate the courses for him using a joystick controller I don’t want to help force because I’m lazy and my candy won’t eat itself and so so far We’ve given force control of the joystick even though he has no understanding of courses In which how you doing over there forest? Okay, let’s get started this little Network now This is the part where everything starts to get a little gray area you? Please keep in mind that neural networks is still an open research field but I’m the best I can to make this all is intuitive as possible without getting all caught up in the maps and logic so Let’s get started ah actually wait. I’m sorry before we can write our no network We need to first set up our inputs forest has control the joystick But he has not even the slightest clue what to do with it He has absolutely no understanding of the course at all which is actually not only super interesting But probably the most important thing to think about when it comes to neural networks. Why well because Every single part of your network depends on the quality of your inputs Let’s look at when I had control over the joystick How did I have an understanding of the course well using my eyes? I was able to send live data to my brain Which thankfully was smart enough to? Determine how far away the course walls were and chorus and then send that live data to my finger nerves or whatever so that I? Can use the joystick correctly with the power of no networks? We can give forests a brain and kind of sort of simulate this same exact brain process now This is the no network structure them deciding to start with five inputs four hidden layer nodes and one output Instead of giving force to eyes or even one that can see actual images We’re instead going to take a more simplistic approach and give him five distances relative to his body as input which are straightforward Left right forward right and Ford left horse will then pass this data to the four hidden layer nodes Which each have five connections? one for each input each connection will have its own strength value and each node will have its own bias that will help shift the to technical just for now know that the bias is very important for each hidden layer and Output node now what the hidden layer acting as forest brain his brain will do some Calculations on the five inputs using its connection strength values and biases those calculations are then sent to the one output node which again has its own bias and connection strength values connected to each of the hidden layer nodes and Finally the output node will be able to calculate a guess for forest the other two justic left or right I know it’s a lot to follow. Just bear with me it gets better I promise and this entire new network alkylation will happen over and over and over again in real time because force Distance when the course will also change in real time I hope I’ve explained this simply enough that you’re still with me because we are far from out the woods Forest with this now new neural network brain doesn’t mean that he’s instantly artificially intelligent Wow what a tough audience hold on to say ah Yes basic underscore laugh track three that way at least you always understand me Anywho forest is still far away from showing any signs of intelligence? You’ll see that if we give him this brain with random values and watch what he does with the joystick. It’s a little bitter I guess But still far from intelligent you see when writing no networks in most cases is broken down into two main parts Designing the artificial structure, which is what we just did and training the artificial structure Which is when the intelligence part comes into play, but? Whoa this has already been a lot of info to take in and we’ve barely just got started with this project So I’m gonna be merciful and give you guys an intermission however I do want you all back in their seats next week so that we can continue this adventure and train force they become the any Course running master all right guys. I seriously Hope that you’re having as much fun as I am with this project Because there’s another part coming next week in which we actually start to Train forests and see some intelligence start to shape It’s super exciting if you ask me if you have any Suggestions or any questions that you need me to clear up you just want to talk about machine learning post in the comments I will be replying to everyone because I Just love this subject so much other than that if you want live updates on this project I invite you to follow me on Twitter at stuff stuff’s my handle I post live updates on this project, but also this random stuff, so let’s chat. Just follow me come on Let’s be friends really speedy curiosity and next week we start to train forests. I’ll see you then As you know I should have walked away, yeah