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.

  • So Daniel wrote, um, basically forked the the python SC to package and then added in on end methods.

  • So, um, all you really need is one Take that package and only need to do is, like all put a link in the text based version of tutorial and what you all you need to do is just download and unzip the package.

  • Put that in your you know, your project directory, and it will use that they're um, Other than that, you probably don't need this.

  • This is where I'm saving the training data on the server.

  • But maybe like here or maybe local here, this might be your on end method and you don't need If you don't need to call this yourself if you use the updated package.

  • Theon end method is called now, um, other than that, um, trying to think there's anything else I need to change there.

  • Kind of is, I probably need to pull that package because I can't.

  • I gotta test it and make sure it works.

  • Um, so let me copy.

  • I think it's actually this copy paste.

  • Um, yeah.

  • Okay, so hopefully in the tutorial code now have the S E two updated package.

  • So, um, so if you downloaded that, it should just be this and you'll have all this stuff.

  • Ah, you might I forget if what she's got in there.

  • I don't know if he modified this for himself or not Forget.

  • Oh, I modified it.

  • I wonder if he can't remember.

  • Anyway, it doesn't matter.

  • So, um, if you wanted to buy the way, you can import Os and then use something like this So if your path stars crafted Starcraft stuff and then Starcraft two, you can change your path that way, and it will find the maps for you if you want to change it.

  • But I've modified mine.

  • Uh, okay, so now look, I think I would need is import time, and that should be about it.

  • The only other thing is, since I wanted to run this headless to create the data I also did at a headless equals truth.

  • And then down here, um, I just basically did this.

  • Like if, but if not or rather if yeah, if not headless, I can't think straight anymore.

  • Uhm, boom should be what I did there.

  • Yeah.

  • So if you, um if you wanted to visualize data, you could.

  • But I've been running this on a national Lennox server, so we don't really want to see it anymore.

  • What?

  • You couldn't It would throw in error if you tried to show it.

  • Which reminds me when we add stuff to train data.

  • Just take note.

  • We're adding self doubt, flipped again.

  • Don't screw up and add the resize.

  • It would be a waste of data.

  • Okay, I believe I believe we're ready to run.

  • Let's see.

  • Hopefully don't get in there.

  • Oh, did I?

  • I think I said it's a true, huh?

  • I did Moon visualize anything.

  • We should see the game, though.

  • This that won't apply to the pop up game.

  • I just want to make sure it actually runs.

  • And then if it does, uh, well, it's probably yell at me because the directory that I asked it to save in doesn't exist.

  • Um, so on end trained data, I should probably add that in.

  • So I just did this new train, Peter.

  • Okay, Hopefully it'll save it in there.

  • But also, they will only save it if the result is a victory, which it probably will not be Because we're fighting difficulty hard.

  • So maybe I'll change that too easy.

  • Over re victorious has no attributes flipped self dot Oh, wait, Hold on.

  • Okay, so ride.

  • So the other thing at this, the results of copy pasta.

  • So it should just be You should just need to say self dot flipped, boom.

  • And then when you at when you do the re sizing, self doubt flipped because we we want to be able to access this variable l swear.

  • Um, so yeah, that should be it.

  • Also.

  • Now we're fighting easy and had loose.

  • I'm gonna change this to false for the next time.

  • If there is another heir now, um, regardless of, however this pans out, um, you do not have to make your own train data.

  • I am going to do it.

  • This will take four ever to make good data because you probably don't really want to always fight the easy.

  • But you probably want to just fight the hard one to create good quality data.

  • Um, so it's taking a really, really long time.

  • So I'm running about 100 games simultaneously just so I can collect data, had reasonable rate.

  • Um, and I'll just share that data with you guys, so you don't really need to worry about it.

  • But if you wanted to, like, modify things and run it yourself at least now you have a good idea of how I, you know, went about collecting the data and all of that.

  • So is this our observer?

  • Yeah.

  • So we won't I won't really know until we actually have void raise you, like, right now, it's just our little observer, but that should work, should not throw in here.

  • Okay, so now we do have a unit.

  • Can't find drop off ago, Cece for a probe and I can't recall.

  • I think we're fighting the easy Easy bought.

  • So we should actually come through with a win.

  • It should save the result.

  • And then all I did was just save it under the time.

  • So, like, whatever the current integer value of the time is, is what I saved it as Where is sublime area?

  • So on that on end method, I'm just saving it is wherever the time is, basically all right, game.

  • Let's hurry up and kill this guy so we can make sure our data saves.

  • It's not looking very well for him.

  • Ah, if anybody has a better idea for how we can let's see if two there we go for how we can.

  • If there's a better way to access the game's result, I know you could say like results equals and then the run game and get the result that way.

  • But then, if you ran to bots, I'm just not really sure how you would go about about doing that unless you, like, ran them in a really specific order.

  • Maybe.

  • And then you could, like, just know the order.

  • So I'm not really sure.

  • But this is the path that we chose this game.

  • Better be over soon.

  • There we go.

  • So on and cold we got a victory, and then we come in here and boom, there's our training data.

  • And the training data isn't early.

  • All that long is usually, like 30 to 60 choices Max per game.

  • That's why you want to run a lot of games because they take a while.

  • Okay, so that is it for now.

  • The next time you see me, I will have a gigantic training set for you.

  • Well, a sizable training said that's good enough for training neural networks.

  • Anyways, um, if you have questions, comments, concerns, suggestions, Have I made some mistakes?

  • Some stupid choices?

  • Let me know below.

  • I know you will.

  • So anyways, um, that is offered.

  • Now, I will see you in the next tutorial.

what's going on already.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

構建神經網絡訓練數據--《星際爭霸II》中的Python AI教程第9頁 (Building Neural Network Training data - Python AI in StarCraft II tutorial p.9)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字