Placeholder Image

字幕列表 影片播放

  • what's going on already.

  • And welcome to part nine of our A I in Starcraft two with Python tutorial.

  • Siri's in this video.

  • We're gonna continue working on what we've been working on, which is applying deep learning Thio, Starcraft two.

  • Now, of course, before we can do any machine learning, we have to build our data set.

  • And that's basically what we've been focusing on so far.

  • So up to this point, we've got quite a good visualizations, quite a good visualization of the map and what's going on?

  • I just want to add a few more visualizations, and that's gonna be things like, How many minerals do we have?

  • How much gas do we have?

  • And then I also want to see a visualization of our like our just our population supply.

  • How much of that I have we exhausted like ratio of that and then also like a ratio of our military unit store worker units so we can see on the map usually pretty well like how many, um, military units we have versus how many workers but things that we can't quite as easily see is like how many units we have compared to our supply.

  • I mean, maybe the network could learn to count the pylons or something and figure it out.

  • It's totally possible, but I thought I'd be somewhat useful to display certain things in, like, ratio form.

  • So that's the last thing I'm just going to add.

  • And this methodology of displaying things isn't necessarily going to be learnt Herbal by the network.

  • I think the bar length is totally doable, like how long the bar is.

  • But in general neural network, artificial neural networks tend to learn more like patterns rather than like a length of a thing.

  • Um, but I'm just gonna throw it in there anyways, so just to see So anyways, um, let me just do this again.

  • Um, there's not too much point.

  • This should be self explanatory type code.

  • Let me go to where we're drawing things.

  • And just after Anethe, after neath underneath obs, we will just paste all this boom.

  • So what we're gonna do is display or minerals.

  • So the game really would have no idea of knowing, like, how many minerals do we actually have?

  • So that's how I'm going to show it.

  • Just with a little ratio of a bar If we have more than 1500 then we're just going to show it as, like, a full bar.

  • And then we're gonna do the same thing with the best being we're gonna do something similar with population.

  • In this case, we're gonna say supply left oversupply, Cap.

  • So how close are we currently do?

  • Our cap again?

  • Visually, the network could maybe learn that, but given if units were over it, you know, maybe not.

  • So I want to make sure we have that totally clear.

  • And then, um and then I have, like, a military units kind of ratio compared to our workers.

  • Um, and actually, in this case is just military units over our entire our entire supply and actually don't see plausible supply.

  • Oh, I do see a plausible split.

  • Okay.

  • Okay, guys.

  • 200 max.

  • Anyways, trust.

  • See if I ever actually used that.

  • Okay, so, um, anyway, then we come down here, and then we just draw each each line.

  • Then we're just kind of color coding those lines, Um, a little differently.

  • So let me just go ahead and run it.

  • I think that the visualization of what's going on well, we'll just help?

  • Quite a bit as we have done recently.

  • The recent members slash sponsors.

  • Um, on de harnessed clum a wisp, our Eo Howard Liang and lizards.

  • Mona, thank you very much for your support.

  • You guys are amazing.

  • Okay, So as you can see here we have the You know, the bars basically, and these are in order, so I actually purposely flipped them around.

  • So this one here is worker to supply ratio.

  • Um, and then we have the plausible supply.

  • So this is just our current supply out of 200.

  • So as this gets bigger, um, is it plausible spice supply?

  • Oh, yeah.

  • Because we just built the nexus, and then it bumped up.

  • So actually supply is well, Yeah, OK, that's our That's our, um our quota.

  • I'm planking on a good word.

  • Um anyway, uh and then the alec down here, this is how much invest being we have.

  • And let's just check to make sure we've got a lot of SP in and not so many minerals.

  • Yes.

  • So we're definitely We've got quite a bit.

  • And that's usually the case.

  • We spend minerals much quicker.

  • Or maybe we're getting vest mean much quicker tomorrow.

  • Um, but yeah.

  • Okay.

  • So, um, so now that we've got that visualization, um, the I think the visualizations pretty much done.

  • There are some things I'd like to do.

  • Like when the scout flies, you can see how, like, as it goes up, it loses units, and as it goes down, it loses units again.

  • I'm not really sure if we can get that radius a little larger.

  • Um, because I do like how he, like, flies around randomly.

  • I don't think I'd want to hold him in the same spot.

  • Another option you have is to just keep sending scouts.

  • Um, honestly, I just thought of that just now.

  • That's probably a really better, more efficient.

  • Where the heck is this one?

  • Yeah, How many spaces is only takes in one of takes away one of our spaces.

  • And I believe generally we actually pretty much always have enough supply.

  • Like I don't think supplies ever an issue until really late game.

  • Wonder about sending like an observer here.

  • Here.

  • You can't see what I'm pointing to get back up here sending like you can see this.

  • Uh, here and then you can't see this one unfortunately, but like up, you know, up to the You see this mouse?

  • Okay, so an observer here, here and here, like these are gonna be like, if you actually look at these maps, the reason I like your start point here is has basically a choke point.

  • There's, like, only one way to get here, and you've got to come through that choke point.

  • And then as you expand out, like, here and here, there's, like, two points.

  • But then, if you go any further than that, it's like you can get a tax really easily.

  • So would be useful to at least send three observers out at any given time to each of these locations and just always hang one over there.

  • I actually think that's a really good idea.

  • I think I'd like to do that.

  • Um, unfortunately, already begun training data, so I'm gonna go and see this one through, but I think in that if this is anything promising at all, I might want to change the data to something more like that.

  • That would be much more informative, I think.

  • All right.

  • So, um, that looks good.

  • I'm happy with the little bars down here.

  • And maybe it'll be useful.

  • And maybe they won't.

  • Who knows?

  • We'll see.

  • Um but we won't know.

  • Anyway.

  • Um okay, so now the you last things that we need to do our modify the attack method, Um, I think that's really it.

  • Uh, modify the attack men, and then we actually don't need to add one more.

  • One more thing.

  • Um, so yeah, so let me eso First of all, I guess we'll do the attack method first, and then I'll talk about the other changes that I've made so coming down here, and they're gonna replace our attack method with the new method.

  • Boom exit out of that.

  • So what we want to dio is we're just gonna choose a random choice between zero and three pythons.

  • Random isn't the most ideal, so you'll notice there will be a lot of patterns and stuff like that, but it should still over a long enough time frame produced at least balanced data.

  • Now, um, we're gonna say target false for now.

  • Um, but if we do find a target, will attack that.

  • Targeted.

  • The way we're gonna find that target is, um, if choices zero, we're just going to wait a random 20 to 1 65 and then we're gonna modify this self ourself, do something after we're just going to say that it's the current iteration, plus the weight so self.

  • Don't do something after.

  • I don't think we have to find it here.

  • We'll add that to our innit method here in a little bit, but we got one more thing we're gonna have to add, so I'll get there.

  • So So if the choice is zero, it just means we're not Don't want to do any attack.

  • We wanna wait.

  • So this will be a scenario where, you know, ideally the A I would learn that when I don't have many units to send out to attack, it's a bad idea to attack.

  • In general, if you just send like, one unit at a time, you're gonna lose.

  • It's not gonna end well for you.

  • So again, just threw a simple, like Evan evolutionary process.

  • We should find that that's an unsuccessful thing to do.

  • So we should have training data that overtime doesn't do.

  • You know, it waits to build an army that's of a size that makes sense for the enemy.

  • That we're gonna fight.

  • But also, you know, you might need a few less to defend like your little base.

  • But you might wanna have, like, I don't know, 10 at least void raised before you go to the enemy base.

  • But if you're just trying to defend yourself against a smaller little army that they just sent to you just to give you a hard time or whatever, you might not need a CZ many, but also you might not always want to address when they send, like, a little fight over to your base.

  • He might want to ignore that and just go straight to their base and decimate them.

  • So just keep that in mind as well, especially this in their entire army.

  • If you can defeat, they're like all their buildings before they can defeat all your buildings, you'd be better off just going straight to their base.

  • So, anyways, um, if the choice is one we're just saying, OK, that's gonna be attacked the closest or attacked the enemy unit that's closest to one of our nexus is and so we can just do that with the following will string of of of methods here.

  • So It's just self dot known enemy units and then closest to is an attribute that's just built in.

  • And then we're just saying closest to a random choice of one of our nexus is you could generate through all the nexus is and then figure out which enemies close or whatever.

  • And that would probably a way better idea, because maybe they're not close to any of the nexus is.

  • But if that's the case, like if they're close, really close toe one, but not the other ones.

  • You've probably expanded really far in the map, and you're really late in the game.

  • And it's not a big deal at this point, like you've made a mistake.

  • If you made it that far.

  • Probably.

  • Okay, um, choice, too, is attack enemy structures.

  • Super simple.

  • Just random choice of known enemy structures.

  • Um, interestingly round choice.

  • I wonder.

  • I haven't actually seen that error out, but I don't think you could choose a random choice of none.

  • I feel like there should be a trying except in like all of these.

  • Do I not?

  • I can't believe I don't have it.

  • I haven't seen myself hitting a lot of errors, but I can only imagine.

  • I guess by the time you've hit like, you can start iterating through these like the only time we will ever go through.

  • These is if we have vital.

  • I don't avoid raise.

  • Um, So I guess maybe that's why it's been so rare.

  • But there's going to be times where you can't make a choice because you don't know of any enemy structures, so that could be pretty problematic.

  • Or that could be problematic late in the game.

  • Like if there's an enemy structure kind of hidden away, and you just never saw it.

  • I should probably try and accept that one, but I'm gonna leave it for now.

  • Um and then finally three.

  • Attack the enemy start.

  • If we do have a target, will attack it.

  • Otherwise, forget about it.

  • Um, And then here we was making the training data again, just like many of our examples and deep learning.

  • Um, you know, if the choice is zero, that means like the zeroth element is one.

  • So we're using a one hot array, so we want the neural network to produce an output like this, and this would be zero, you know, it would be no attack.

  • Conversely, if you had something that was like zeros 010 that b 012 So attack enemy structures.

  • Okay, so that's all that is.

  • All right, so now we've got the data, but then you'll see we're a pending the training data to this self doubt train data.

  • So that's the other thing.

  • We want to go ahead and add two.

  • And we probably don't need to print this out anymore.

  • That was just for debugging purposes.

  • So then I'm just gonna go to the top here and inside the innit method.

  • I am going to add a couple of things.

  • So first, we're going to say self dot do something.

  • After I'm gonna say that's equal to zero, and then self dot train underscore data for now will be an empty list, and then at the end of it, we're going to save it.

  • But we're gonna talk about that in just a minute.

  • The other thing, I kind of want to talk about us, do something after I feel like maybe I didn't stress that one enough.

  • So why?

  • Why would you wanna wait?

  • Um, let's say the choice is zero.

  • It's don't attack.

  • Why am I waiting there for iterations?

  • Well, I don't know if this range is the best, but you wanna wait Because Because every iteration we're gonna come right back to this question, right?

  • Which one random choice do we want to do?

  • So if you don't force himto wait for some time when the choices wait, your training data is going.

  • This option will always be a worthless option because, like, literally in the next generation, you're a I randomly chose to do something else.

  • But in reality, if do nothing is really the good choice than you actually probably are gonna want to sit there for more than one iteration.

  • You want to sit that you're probably like, If that's the good choice, you should sit there for who knows how long, but some duration.

  • So that's why I wanna wait there, because otherwise the wait would be worthless.

  • It wouldn't actually, you know, you'd have ah, such a small chance that you would wait for more than even one or two or three operations.

  • So I wanted to just do a random range of 2165.

  • And those numbers I just made up so.

  • So, Yeah, because, like, think about it this way.

  • If choices one What happens?

  • Well, that unit is no longer idle, and it's probably not going to be idle ever again.

  • It's going to die busy.

  • So So So that's why we want to make sure that these think these choices really are balanced choices.

  • If anything, you might want to wait a little longer than that.

  • But 165 is a minute.

  • In my times, there might be a way to, like, reference game time.

  • Or you could use the time, you know?

  • Well, you can't really import time unless you plan realty time.

  • Um, I don't think I've seen a game time.

  • If someone sees a way in, there might be something in the body.

  • A class to reference the game time Someone knows how to do it.

  • Posted blokes.

  • I don't think I haven't seen I haven't come across it, but it would be a better choice than using it orations.

  • Okay, so, um okay, so that is our attack options.

  • Do we add everything we wanted to use the train, did it?

  • Okay.

  • I just wanted to explain.

  • Do something after.

  • Okay, So the four.

  • Final thing is we want to We want to be able to reference the result that we get from the game because we want to save the game.

  • If the result is we won.

  • But eventually we're gonna want to be ableto pit sent a bought against itself.

  • So in order to do that and save the result, I feel like the best way it would be to use some sort of built in method that knows who the winner is.

  • Unfortunately, when the game ends, your bought doesn't know it, so that's not very good.

  • So in least for the time being, um, the choice that we have gone with is to add in on end method to the bots.