Placeholder Image

字幕列表 影片播放

  • what is going on?

  • Everybody welcome to part two of the artificial intelligences in Starcraft two with python tutorial.

  • Siri's INS video we're really doing is building on the last video, continuing to build up our starting game methodology.

  • So the things here are pretty pretty simple and pretty rule based.

  • You have to, you know, create workers, distribute workers, collect your resources and then basically, kind of from that point, you can start to strategize how you want to do things.

  • But first we have to get through quite a few just kind of basic things.

  • Now I forgot to mention in the previous video Most of the time people ask Hey, what are the pre requisites to this Siri's?

  • My answer is honestly, always the same.

  • But I should have given it anyways that, like none there never prerequisites to really anything like you just follow along.

  • And then any time you hit something that you don't understand, research it, go to Google, Look for a tutorial on it, whatever.

  • So, for example, you know you might not understand inheritance.

  • Well, you can go to Python program net type in inherit search, boom, inheritance Easy.

  • Uh, maybe you don't understand a sink.

  • What's What's that?

  • A sink.

  • Oh, a sink.

  • Io basics.

  • Okay.

  • And then you can learn about a stink eye.

  • Oh, right.

  • So if you're having trouble with anything, research it or ask in the comments for someone to help you Because if you try to learn everything before you're gonna learn like new topics, a lot of times you're gonna find yourself always learning the basics in.

  • That's really boring.

  • So, anyways, there you go.

  • Those of the prerequisite slash a life lesson.

  • So So let's get started.

  • Um, what we've got here is we've distributed the workers.

  • The next thing is we want to produce more workers.

  • So let's go ahead and do that now, in order to produce workers, um, I did link to this in the, um in the text based version of tutorial.

  • But this is like a good a good little resource for someone like me who has no idea what they're doing.

  • So at least this is for the pro tossed units, and you can kind of see what it takes.

  • It's like the tree for building things.

  • So you start off with a nexus, a nexus with an excess you produce are you can produce pylons and assimilate.

  • Er's like you basically start with the ability to do all of these things, like so with a worker.

  • Now the nexus itself produces the little probes, the workers, then you from there.

  • Once you have a nexus, you can build a gateway or a forge.

  • And then from here, you can build like if you have a gateway, you could build a cyber nice core if you have.

  • And then clearly it looks like if you have a cybernetics core Wow, look at all the things that opens up for you.

  • So there's, like, this path that you can take to various things.

  • We're going to revisit this soon, but, um, you have workers here now, In order to produce workers, you just need an access, so that's relatively simple.

  • So what we need to do is that since that nexus produces it, we need to be able to reference a nexus.

  • So from sc two dot constants, we're going to import nexus and also probe because we want to produce a probe.

  • So now we're gonna do is we're gonna come down here and, like in this case, this on step.

  • It runs every step.

  • I don't really know what a step is.

  • It's like not I think it's not like a second.

  • I don't think it's a fixed time.

  • Even I'm not really sure.

  • Um, it might be like a game tick, which might actually be a fixed time.

  • I don't think it's tied necessarily.

  • Two frames.

  • That would be kind of weird.

  • Um, but it's some sort of adoration.

  • I just don't know exactly what it is.

  • If you happen to know what each step in the game is, let me know.

  • Um, anyways, so in here, this this little on step is gonna contain all of the methods that you want to run.

  • Just it's gonna call all the methods you want to run per step.

  • But then you might not get so lucky that distribute workers was already written for us.

  • Awesome.

  • But that's not gonna happen like so for now, like to build workers.

  • Our function for that is not going to It doesn't exist yet or our method rather So what we're gonna do, though, is we're just going to say, let's say, await self dot Build underscore workers.

  • So we still call it the same as this, but it just doesn't exist yet, so we have to define it.

  • So we're gonna come down here a sink deaf, build workers again.

  • You're gonna need to pass self here.

  • Otherwise we're ready to actually build this dysfunction.

  • So what we're gonna do tow build?

  • I'm sorry.

  • I'm gonna keep calling it a function.

  • It's a method.

  • Anyways, we're gonna build the speck that what we need to do is four next nexus in self units, that air of nexus.

  • So for every nexus, um, that we have that is ready, Ready?

  • And also, um, has no Q u e.

  • I always have a hard time.

  • Q.

  • So what's this mean?

  • So the nexus itself has to be ready.

  • I e.

  • It's built.

  • It's not pending.

  • And then no Q means it's not producing something else right now.

  • So for humans who are slow, um, and can Onley focus on so many things At any given time, there are key build cues, So you could say, OK, I want this building to produce five workers and then you go deuce other things.

  • So, like when one worker is done, the next one starts up.

  • Okay, that's what the Q is for.

  • But we're running programs.

  • The program can manage all of your buildings in all of your units simultaneously, so there's really no reason to add to a Q.

  • You're just kind of allocating.

  • Resource is for no good reason.

  • Like it's it's slightly disadvantageous.

  • Thio havoc you.

  • So no reason to do it.

  • So now we're gonna do is so for each nexus that is ready.

  • What do we want to do?

  • Well, we definitely We'd like to build a probe, but we need to make sure we can actually afford one.

  • So if self dot can underscore afford so if we can afford a probe now, can't afford is a method that's tied to self.

  • You don't see it defined here.

  • So, uh, it must be inherited.

  • And it is It's one of the methods in there.

  • So if we can afford a probe, then what do we want to do?

  • Well, we want a probe.

  • So all we need to do is we can just say, um await.

  • Not all caps await, self dot Do so what do we want to do?

  • What we're gonna do in nexus?

  • So it's just this nexus object that we found that was ready with no Q.

  • We want a nexus dot train and we want to train this probe.

  • Okay, And that's it.

  • Now, now we're building workers.

  • Let's go ahead and run this and make sure it actually, it actually works should pop up.

  • There it is.

  • So barely immediately.

  • Once we have resource is at least we should see that we start to produce a worker, and there it is.

  • So it's already warping in a probe right now, which is just the, um, the word we used to describe bringing in units for this class.

  • So it warps it in, and immediately you can see it actually produces another one.

  • Um, instantly, it almost looks like we did call it despite being waited in Q.

  • I guess that's how quick it went interesting.

  • Um, anyways, that wasn't really supposed to happen.

  • I just the first time I've noticed that it does that.

  • But you've already allocated the resource when you do that, that's the downside.

  • Let's see what happens when we produce this one.

  • Yeah, immediately to our maid and arresting.

  • So what you can see now is we need more of these quote unquote pylons.

  • Because if you look up here, this is how many.

  • This is your supply.

  • We have 15 out of 15 so we've got 15 units we we can't create any more.

  • Now with the pro toss class.

  • The way that we create units or increase our supply is with, um, pylons.

  • No pylons do.

  • Two things.

  • One, they increase your supply.

  • But they also have this, Uh, What's the name of the thing?

  • I can't think of what it's called.

  • It's like a psionic, I think.

  • Ciaa nick something, uh, let me pull up the tree here.

  • So I linked to this in the text based version, but yeah, it's like this is like the tree that you know what you need to build certain things.

  • So you start off.

  • Let me do this, man.

  • Uh, do this.

  • Okay, so we'll start off with the nexus, and you can build pylons and assimilate er's and a simulators or what we're gonna build pretty soon.

  • But then let's say you want to build like an army while you're gonna need to build a gateway.

  • And with that, you get dizzy a lot.

  • But then, if you build the cybernetics core, you get access to all these other things.

  • And then from there you get access to all of these things that you can build.

  • And so on.

  • It was what I'm interested in here is the pylon where they called it a psionic matrix.

  • So you can on Lee bring it.

  • You can only build buildings and warp in things as long as it's within this Ionic matrix and each pile on, um, adds to that's Ionic Matrix.

  • So one thing we could do, I think it will be the shortcut.

  • Would be BP probably.

  • Nope, I thought it would be.

  • No, it's gonna be an E.

  • So one thing you can do is when when the program is running.

  • If you're curious about something, um, and you want to learn more about the game you can like, click on one of your workers Now, eventually it's gonna get a new tax, so you could be kind of quick, but there's always shortcuts.

  • So be is billed, and then you find like I wanna pile on So hee so you could hit B e pretty quick and then so say Okay, I wanna pile on right here.

  • So if we build, this pilot is gonna take a second to build.

  • But once it's done building, it's gonna add to our account here for how many units we can have so immediately you'll see these guys will start warping in, actually, um, and then you can see this little circle around here, and basically, that's your CIAA Nick Matrix.

  • And so you can build more buildings inside that matrix.

  • So, as you can see now, where Max units is up to 23 click over here.

  • Sure enough, it's creating more workers for us.

  • So what we need to do now is build these probes so I'm just gonna exit.

  • And so we want to build.

  • Um I'm sorry, not probe pylon.

  • Everything's a peak.

  • So?

  • So the next thing we're gonna dio is the weight, self dot build underscore pylons.

  • So then we're gonna come down here.

  • I'm gonna clear this out.

  • So have space a sink deaf build pie lines, and in order to build the pylons, we're gonna pry need to access their type.

  • So high line and now we want to do is create some logic, so we don't want to just like constantly built pylons.

  • It's a waste of resource is and it gets in the way and all that.

  • So So we need to have some sort of logic.

  • So the way that we're going to do this is weird to say.

  • If self don't supply left and again, supply is kind of unfortunate naming convention, if you ask me because supply references and so is units, by the way.

  • It's like I'm pretty sure unit's core responsible buildings and your actual, like combat units and your workers.

  • Anyway, that's beside point supply.

  • Left is how many is like supply is interchangeable, really with population, so supply left.

  • So if your supply left is, let's say less than five, Um, what do we want to do?

  • Well, we want to build a pylon, but what if we're already building a pilot?

  • So if the supply left is less than five hand self dot already underscore pending.

  • Um, I'm sorry if and not self already pending pylon.

  • So if we're not already building a pylon, what do we want to do?

  • Well, we want to grab.

  • The nexus is so we're just going to say next this is equals self dot units.

  • Nexus don't ready.

  • So it's a nexus that already exists.

  • Um, so if Nexus is dot exists, if self dot can afford.

  • So if we can afford that python I thought pile on.

  • I think it's about breakfast.

  • Time for me, man.

  • I can't think await, um, in this, in this case we want await self dot build a pylon.

  • But when we build things, we also have to specify where So again, this is a very complicated thing.

  • And we're at least for now we're gonna use near equals.

  • Nexus is dot First, So we're just gonna build it close to our very our initial nexus.

  • So which is also a funny sounding word for a command center that you can have multiple nexus is.

  • Anyways, um, we're building the 1st 1 So already, though.

  • So, like, right now, everything is rule based in, but But where you could begin to start using things like reinforcement, learning or just deep Loring in general, is even this.

  • Where do you want a place that nexus and like, how do you want to distribute your workers?

  • How many should go in different places, these things or extremely complicated?

  • So even just that little tiny thing like where exactly?

  • Should we place this pylon?

  • That's a very complicated thing.

  • And so to be best could because of that's Ionic Matrix.

  • That's actually a very complex question.

  • So anyways, this one's gonna be super simple.

  • We're just gonna build a close to an excess.

  • But if you wanted to be very efficient about it, um, you would need to be smart, have a much better reasoning for it.

  • We probably should have.

  • Oh, crashed.

  • What do we do?

  • Do we not Pat?

  • Okay, seen this one before.

  • So in case you run into this one, it's okay.

  • I guess that we run into errors because probably hit it at some point type air build pylons takes zero positional arguments, but one was given.

  • What?

  • So what's happening is we forgot to pass self.

  • So because this is a method self, the object is gonna get passed into here.

  • We need to make sure when we define this method that we include self here because it was happening right.

  • We're actually run.

  • Self is running.

  • This methods of self is passing.

  • Later on, we might build functions that don't need itself to be passed, but in this case, you need to pass self.

  • Anyway.

  • We'll try again.

  • We probably could turn off real time now, but we'll see the result of this pretty quickly.

  • Um, and then probably pray after we see this.

  • Oh, my gosh.

  • Do we hit another?

  • No, no, it's okay.

  • I just didn't see the game.

  • The game was supposed to pop up and clicking around.

  • Hopefully, we're already building workers.

  • So any any moment now, as long as once we get the required resource is we should find that we build a pylon.

  • There goes a pylon right now over here.

  • So yeah, just so it's just built kind of anywhere within range of the nexus which, ideally like our next pylon and something that we're going to see.

  • Like if I was to speed this up, we would find that it's gonna pry building that.

  • Well, it doesn't necessarily have to, but ideally, you'd probably build the next pile on, like I'm pointing to, you know, maybe the next pile in here or here.

  • Probably here because it's more defensive back here.

  • No one can come from back here.

  • They're all gonna come from up here anyway.

  • you build maybe your next pile on here, but we might find that instead it builds the next pile on just right next to this one, which is pointless.

  • So, yeah, you pry eventually want to optimize that one quart a bit.

  • But for now, that's good enough.

  • So already let's see, It should be less than five.

  • So once one more is warped in, we should see that another pylon is built.

  • Uh, did it come in for some reason, I guess we're still.

  • Why are we still five down?

  • That's us.

  • Were we were okay anyway, so immediately when another one was built.

  • Boom.

  • There goes next, Pilon.

  • Anyway, um, and then why are we That's kind of interesting that there's two at the same time, I'll have to check the logic on that one.

  • Um, like no que, it must just be happening so quickly anyway.

  • Okay, so we're building pie lines were creating more workers were expanding everything.

  • But like I said, it's basically pointless for each each patch of minerals to have any more than three workers on it at any given time.

  • So we're going to exhaust our area here quite quickly.

  • So what we need to do next is actually expand to other areas.

  • So we're gonna do that and then pry work on building.

  • So right now we've got workers, but we don't have anything to actually build an army.

  • So I think in the next tutorial, what we'll do is both expand to new sites.

  • You can see them on the map like this is a new site.

  • This is a site.

  • This is a site, and basically all these little sites will have these little vest peen guys er's and this is where you're gonna collect this element here, this best being gas.

  • Um, anyway, so the next one we'll do is we'll start collecting the gas building what we need on here to collect the gas building, the buildings that we need to create our army.

  • And then probably maybe after that, start building our army because even because at that point, the strategy already forces its way in with things like, you know, we only have so much supply.

  • So how much of that should be our army versus our workers and all that stuff?

  • So anyways, that's all for now.

  • If you got questions coming to search whatever.

  • Feel free to leave them below.

  • As always.

  • Thank you for all your support and your sponsorships and all that cool stuff.

  • And I will see you in the next tutorial.

what is going on?

字幕與單字

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

B1 中級

工人和鐵塔--《星際爭霸II》中的Python AI教程第2頁。 (Workers and Pylons - Python AI in StarCraft II tutorial p.2)

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