GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Build Build
Jasper Geurtz edited this page
Now that we are training our workers, eventually we'll be running out of supply. To do this, we need to build some buildings that give us extra supply space. Again for larva.morph(UnitType.Zerg_Overlord); Giving a command to build a building is as simple as worker.build(building, location); However, figuring out what, who, when and where you should build is not that trivial. Something that gives supply UnitType toBuild = self.getRace().getSupplyProvider(); A random worker that is not already doing something except gathering minerals (as to not disturb a potential other future builder or future scouter) Unit builder = null; for (Unit unit: self.getUnits()) { if (unit.getType().isWorker() && (unit.isIdle() || unit.isGatheringMinerals())) { builder = unit; break; } } We need to build supply buildings only if we are going to run out of supply space in the near future (and did not reach our supplycap of 200 units yet). if (self.supplyTotal() - self.supplyUsed() <= 2 && self.supplyTotal() <= 400) { } Note: because of how StarCraft works, You can easily check for yourself with these handy methods unitType.supplyProvided(); unitType.supplyRequired(); Building placement in StarCraft is very important but also quite complex (e.g. walls, canon placement, etc.). For this tutorial however we'll cut some corners and just build around our starting location and use a built-in method to get a TilePosition buildLocation = game.getBuildLocation(toBuild, self.getStartLocation()); builder.build(toBuild, buildLocation); However have a problem right now, where this build condition will be true for a very long time, as long as the building is finished, so a lot of workers will try to build a supplyprovider at the same time. We can add a little hack by keeping track of our "queued" supply, e.g. the supply that we will have in the future. NOTE: this is just a hack to keep the tutorial going, you should implement your own building building tracking system (e.g. my approach doesn't scale at all because it only works for buildings giving supply). Clone this wiki locally |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |