-
Notifications
You must be signed in to change notification settings - Fork 0
Build
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 Zerg
this would be an Overlord
which is morphed from a Larva
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)
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
if (self.supplyTotal() - self.supplyUsed() <= 2 && self.supplyTotal() <= 400) {
}
Note: because of how StarCraft works, Zerglings
being only half a supply on the screen (0.5), supply in BWAPI is doubled compared to the number that the game displays. A Zergling costs 1 supply, a worker therefore costs 2 supply, and a supply building gives double of what you see on the screen. In the end it is the same, only this can be confusing for beginners when starting to work with BWAPI.
You can easily check for yourself with these handy methods
unitType.supplyProvided();
unitType.supplyRequired();
TODO