Skip to content
Jasper Geurtz edited this page Jan 13, 2020 · 5 revisions

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);

Building buildings

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.

What

Something that gives supply

UnitType toBuild = self.getRace().getSupplyProvider();

Who

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;
    }
}

When

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, supply in BWAPI is doubled compared to the number that the game displays. A simple worker therefore costs 2 supply (as counted within BWAPI), 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();

Where

TODO

← previous | next →

Clone this wiki locally