Placeholder Image

Subtitles section Play video

  • What's going on?

  • Everybody.

  • And welcome to Hal.

  • I part five in this part.

  • What we're gonna be doing is building on last tutorial where we at least got a We built the Aye aye, too.

  • Or at least we built a script to pull features and just play the game randomly between choosing three choices.

  • Mine a planet, mind our own planet Attack or mine?

  • Empty planets.

  • Not in that order.

  • So So what we need to do now is we need to have a way to to make these these two players play against each other, Uh, and then we're going to save the winning players plays and they're basically their features.

  • So their output, that's what we want to save.

  • So we've got the code.

  • All done.

  • Ah, but now what we want to do is actually create a script that will just automatically run them.

  • The other thing we want to do is I'm just gonna go over here.

  • The script that we're countering now is data creator.

  • Um, I'm going to call my body, and I'm actually just gonna do my bought Dash one.

  • I'm a copy paste, and this will be my bought dash two.

  • I'm gonna edit that.

  • And I'm gonna change version two to save exit.

  • Done.

  • So now, to run these.

  • Like, if we wanted to compete against ourselves real quick, I wouldn't just saved it, but would be Hal.

  • I don t x c And then my bought one.

  • First.

  • My butt, too.

  • Go ahead and, uh, run that real quick and make sure day I closed it.

  • For whatever reason, if you copy something an idol in the new clothes idol, the copy does not remain anyway.

  • Okay, so these two a eyes competed against each other.

  • Ah, this this dummy only produced for ships did 5 10 damage.

  • This one produced 36 ships that quite a bit more damage on.

  • And we can watch a replay of that real quick.

  • Oh, interesting.

  • I think they crashed into themselves immediately.

  • Both Both the eyes did that, and it looks like he's probably gonna come destroy him real quick.

  • Pretty good.

  • Okay.

  • So, um, so yeah, like watching this guy play even you're like, Oh, yeah.

  • That wasn't bad.

  • So?

  • So not about not a bad set of moves there.

  • So anyways, let's go ahead.

  • And, uh, I guess I'll leave this up because actually, right now, um, I'm running Charles on, uh, on the latest version of this this deep learning I So, uh, I'm an extent out.

  • And yes, so as you can see here, toothy other thing to pay attention to is basically about the input vectors and the output vectors already saved.

  • So you just pull up one of them.

  • So here's an example of an input vector.

  • Quite a bit of data to be showing there.

  • But anyway, there's your input vector.

  • Basically all this data and then that maps to the output vectors, which much simpler.

  • All that data.

  • Okay, so mmm.

  • This, um the first thing we need to do is we need to figure out how to make this call.

  • You know, that that to run.

  • So we're import os, and then os dot system is what we can do to make a system call.

  • And then we just want to run that command, which actually kind of say that saved over here.

  • Just like all the other tutorials.

  • If you just If you want the sample code and exactly what I'm doing, you can go to the editorial, put a link to the description.

  • Ah, you don't have to type all this out.

  • So we just call the system to go ahead and run all this.

  • Now the next thing we want to do is we wait, We need to know who won the game.

  • If the problem is, um from what I could tell, there's really no easy way to determine that at least with highlight Daddy XY.

  • Um, So what we're gonna do is actually we're gonna take this.

  • Ah, which is missing the closing.

  • Weird.

  • How did that run the first place?

  • We're missing the closing.

  • That Anyway, we want to run that and out this data Thio, Uh, we're just gonna call this data dot game out.

  • Okay, so we send the data out to that file, so that's just gonna send whatever runs here to just a quick file, basically is gonna upend the output to that file.

  • So we run that, uh, and then we can parse that file.

  • So, for example, we could just say with open, uh and then dated a game out.

  • And we're just gonna open that with the intention to, uh, read as f we're gonna say contents equals f dot read lines.

  • And then the way it works is I mean, first, we could just run this real quick to say you can see it.

  • Um, but it should have kind of the same order every time.

  • Just waiting for this game to be over.

  • I dated a game out.

  • Here we go.

  • So here's an example of the game out files.

  • So it's exactly what you see in your console.

  • But as you can see here, these are the lines that were after, So basically, uh, so read lines is gonna read by new lines.

  • So this would be the last line.

  • So negative one negative too negative.

  • Three negative for So player one is going to be.

  • Whatever contents negative for is that's gonna be the information on player one or they're calling it number zero.

  • The second player or a player number one is gonna be negative.

  • One negative, too negative.

  • Three.

  • And then from here, we can parse.

  • What rank did they get?

  • Um, you could say how many frames they got through.

  • How many ships did they produce and how much damage did they deal?

  • We can grab all that data, so we just parts it.

  • So that's what we're gonna do.

  • So, uh, we're gonna say Charles Charles bought one is equal to the contents contents, negative four.

  • And then Charles Bonnet to would be contents.

  • Negative three.

  • And then we can just go and print both those out.

  • So just copy that paste, copy paste, and then we'll run it dragged the silver right, so we can see.

  • Okay, we got those two things.

  • Now, sometimes if somebody times out, this won't be the case, and then we'll end up hitting an error, which is okay, well, we'll make it.

  • Um, but yeah, the only time these won't be in that order is if one of the bots times out or it's an heir.

  • Okay, so now we want to do is be ableto parse data from these lines.

  • You could use regular expression, or we could just split it.

  • I'm gonna do splits, and I'm not gonna make you guys sit through me writing this out.

  • Like I said before, I think it's just a waste time.

  • Someone, a paste, get ships, get damaged, get rank.

  • So we split by rank number, go to the right hand side, split by space and go to the left hand side.

  • Boom.

  • Got it.

  • Someone wants to write a regular expression to do that.

  • Have at it.

  • Uh, this is just easier for my little brain to understand.

  • So, uh, anyway, continuing along, uh, what we want to do now is grab that data.

  • Um, and then we can output that data again.

  • Um, I don't see any value in making everybody right this one out.

  • So I'm just gonna copy and paste this one as well.

  • And all this does is grabs.

  • How many ships?

  • How much damage?

  • How much drink for a player?

  • One player, too.

  • One thing I'm going to point out here is you might think about in this case, this is a one V one.

  • Uh, you might think about doing training both one V one and one V one V.

  • One V one.

  • Because both of those matter.

  • So So make sure make sure you consider doing that.

  • If you only trained this a I to do one V one matches.

  • Um, spoiler alert.

  • It will become very aggressive.

  • And it will eliminate your one V one opponents in just a lightning fashion.

  • But, uh, so basically it'll pretty much win every game that the your opponent doesn't flee.

  • But you're gonna lose basically every four player match because you're gonna get too aggressive initially, not get enough planets.

  • You'll probably take out one of the players so you won't get last.

  • You'll probably get third.

  • You definitely won't get first.

  • So anyway, something to think about.

  • But we're just trying to make a simple example here.

  • So Ah, once we have all this information, we're ready to figure out who won and then save the data again.

  • I'm just gonna copy and paste this code because it doesn't make much sense to have everybody write it out.

  • If it was, Charles bought one that has rank of one s O.

  • If that is who won the game, then we want to take that input vector and save it.

  • Or basically a pendant to train dot in.

  • And then we want to take the output vector from player one, then say that to train dot out.

  • We're just gonna keep appending it to train.

  • Got out.

  • If it was player to that one, we're gonna do the same thing.

  • We're gonna take player two's input vectors, save them to train in output vectors.

  • Same save them to train out.

  • Now, there's going to be playing times where, like maybe someone times out immediately.

  • Or, uh, the game just went too quick.

  • Maybe one of the players didn't actually do anything, so he didn't put up a fight or anything.

  • Uh, or whatever.

  • There's only lots of times where something like that happens.

  • So what I'd like to do is create a ship requirement and a damage requirement again, Just like a lot of these things.

  • You can feel free to change these, make them whatever you want.

  • You don't have to do exactly what I'm doing.

  • You can.

  • I'll show you the results of exactly what I did.

  • It's nothing stellar.

  • So the whole point of this is that you guys can kind of tweak it and see where it gets you.

  • So anyway, ship requirements were gonna say we want at least 10 ships for the victor, and damage requirement will be at least 1000.

  • If we don't meet those requirements, we don't save the data.

  • So, uh, so the way that I'm gonna handle for that is basically well, come down here.

  • Um, actually, I think I'm just gonna copy and paste the full code because there's quite a few changes here that need to be made, actually, So this is with the full code now, pretty much the same thing here.

  • I just added this to track percentage winds, especially when we get to the point.

  • What?

  • Once you've trained your I have no idea what that was.

  • Once you've trained your A I, um you're probably gonna want to now compete either, eh, Ivor?

  • Say aye or a I verse random script and save the winners on.

  • Then maybe a Ivor say I saved the winners and keep doing that and literally improve.

  • So I like to track who is winning at the time.

  • Because what we should expect is after we've trained this, um, we should expect to see that the aye aye is better.

  • So when we run, this one will run player one verse player to given enough matches.

  • Let's say we play about 1000 matches or 5000 matches.

  • We should see that player one player to or about 50 50.

  • There should be no reason why one is significantly better than the other, but the hope is after we train an A I that the a I has better percentage went so the way I should be better than player two or whatever.

  • Let's say if athe I was player one, it should do better than 50.

  • 50.

  • Um oh, the other thing.

  • Those I changed this.

  • So this was from my code.

  • So right now it's actually dash one and dashed to in our code.

  • So here it just computes the percentages.

  • Scrolling on down.

  • Yeah.

  • Yeah.

  • Um, here before we write to those files, we just want to make sure that we have more ships than are required.

  • We've done more damage than is required.

  • Also, we want to sleep for two seconds of every iteration.

  • I have no idea why we need to do that, but for whatever Isn't this for me?

  • If I didn't do those two second sleeps, it would like a copy the data.

  • So every time it would run it, would it Would you like five off the game outs?

  • It would save, like, five entire train in train out.

  • It would just five times.

  • So I don't know why it was doing that, but if I put in the sleep that didn't happen anymore.

  • So awesome.

  • That's what I went with.

  • Okay, so I'm gonna go and say that and let's test it.

  • Make sure runs.

  • Make sure it's doing exactly what we were hoping for.

  • Pulled the command prompt.

  • We're gonna do Python data.

  • Dash Creator DuPuy.

  • Uh, let me just go and run that, See if we had in years.

  • One thing to make sure is make sure people are producing ships and doing damage.

  • If you run this and you're not seeing that happen, something's probably wrong.

  • But right now it looks like the running.

  • We're seeing everything that we expect.

  • Currently, it's 33 to 66 but we've only run a few games.

  • Now.

  • It's 50 50 all right, and we're playing games.

  • Unfortunately, there's no way to silence the creation of these replay files.

  • Um, you can just mainly delete them, or what I did was Ah, I just wrote a quick script that would find all the log files and dot hlt files and just believe them.

  • And I just called it clean up that pine.

  • I just double click it Just clear all the all the flats because, uh, you'd like to run this at least 1000 times.

  • But, Holly, um, like, I don't know, 5000 times or something like that to get a good amount of training data, so you'll wind up with a lot of replay files.

  • Okay, Once you've done, um, I would suggest you do at least 100 games.

  • Hopefully at least 1000.

  • And ideally, I don't know, a few 1000.

  • But once you've got a good amount of training data, uh, like I say at least 100 before you do the next tutorial, I think, Ah, once you've got a good amount of training data, we can move on.

  • And then basically this.

  • So this train, where are you?

  • Here you are, Trained file.

  • Is that involves?

  • No, that is not on the screen.

  • Uh, so train it and kill me.

  • Let's do this.

  • Okay.

  • Train in, train out, popping all around.

  • But anyway, still on screen.

  • So training train out.

  • As you can see, they're growing over time.

  • We can just open them real quick.

  • Um, so, so far for sample training data, we've already got 15,000 examples depending on how quick your computer is.

  • These matches can go faster.

  • Slow.

  • Also, if you were to like, I don't know, multi process this or something like that was some sort of lock on the train and train out.

  • The last thing you want to happen is these files get corrupted.

  • They need to always be in perfect order.

  • Right?

  • So number 15,440.

  • Uh, input vector needs to exactly match 15,440 output vector.

  • If that doesn't happen, uh, you're gonna be in a world of hurt, so make sure that that is always the case.

  • Anyway, run this for a while, and then whenever you've got a good amount of trained it, I'll see you in the next tutorial where we actually build a Paris model to train against the train in and out training model to hopefully pick a decent output vector.

  • So I will see their questions.

What's going on?

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it