archive by month
Skip to content

Steamhammer can’t rebuild its last hatchery

While reviewing WorkerManager to find a different bug, I happened to notice a subtle mistake in WorkerManager::getBuilder(), the routine that chooses a worker to construct a building. If there is a worker whose job is to move into position, it prefers that worker. But if there is not, it picks a mineral worker:

		if (unit->isCompleted() && (workerData.getWorkerJob(unit) == WorkerData::Minerals))

It looks correct. If you have workers then should always have mineral workers, unless they are all pulled for other jobs, and then you probably prefer to wait to start the building. But it’s not correct. There is an important case where there are no mineral workers: You may have no bases mining minerals because they were destroyed or mined out, so all the former mineral workers are marked Idle.

		if (unit->isCompleted() &&
			(workerData.getWorkerJob(unit) == WorkerData::Minerals || workerData.getWorkerJob(unit) == WorkerData::Idle))

Without this fix, when Steamhammer loses its only hatchery, it is unable to rebuild. I ran into that bug in January and always wondered about the cause. Theoretically the bug could also strike in the late game, after all surviving hatcheries have mined out their minerals. I’ve never seen it happen, but then there would be no mineral workers and Steamhammer would be unable to construct a building.

It’s not a critical bug. Losing your last hatchery usually means you lose the game. But if the opponent is also in dire straits, you still have a chance. It happens most often in zerg versus zerg.

Now I need to go find any other places where code looks for a mineral worker and make sure it can find an idle worker too. WorkerManager::isFree() was already correct, but there might be more....

Update: The other routines which get a mineral worker and skip over idle workers are WorkerManager::getClosestMineralWorker(), WorkerManager::getGasWorker(), and WorkerManager::getMoveWorker(). Routines outside WorkerManager which do similar jobs all call isFree() as they should. I rewrote these three to call isFree() too.

Trackbacks

No Trackbacks

Comments

PurpleWaveJadien on :

The bugs never stop. I lost a game to ZurZurZur when I reacted to his gas steal by building my second Assimilator in a nearby base instead. 2 bases -> 2 Assimilators -> perfect, right?

Jay Scott on :

We should all thank ZurZurZur. That gas steal has turned up a lot of bugs for us.

Paul Goodman on :

Speaking of bugs, the text of this post is repeated. Or is there a joke I'm missing?

Jay Scott on :

Holy spork, I must have messed it up when I added the update! Thanks, fixed.

MicroDK on :

Ohh gosh! It and the drone dance bug proves that bugs are sometimes hard to indentify... I wonder how many bugs are still left in the code? ;)

Jay Scott on :

I know of dozens that I haven’t traced. The total is probably on the order of a zillion.

Jay Scott on :

There are also a small number of bugs that I know the cause of and haven’t fixed. For example, when a kiting unit is near the edge of the map it may try to kite to a position off the map. It passes an invalid position to Micro::Move. But Micro::Move recognizes the invalid position and ignores the command, so there is not much bad effect. I’ve been putting it off because kiting needs to be rewritten and it’s not a high priority.

PurpleWaveJadien on :

Iron Bot's excellent kiting algorithm is (at its core) surprisingly simple and would be easy to add. It's basically what you're currently doing but with a bit more obstacle awareness.

Joseph Huang on :

Steamhammer has a bug which causes it never to exit an opening early when losing a building as zerg. I'd rather have no extractor trick than such a big oversight.

Jay Scott on :

It’s an intentional behavior that I chose early on. I was unhappy with how UAlbertaBot was ready to abandon its opening at the drop of a hat, so I went to the opposite extreme. I still haven’t decided on the right idea to improve it.

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.