archive by month
Skip to content

production freezes

Production freezes are one of the most serious classes of bugs in UAlbertaBot. Its descendants like Steamhammer and Arrakhammer have mitigated the problem by solving various subclasses of production freeze item by item, but have never solved all of them.

There are two main kinds of production freeze, permanent production freezes caused by deadlocks and temporary production freezes caused by waiting for a slow prerequisite to finish.

There are many ways for production to deadlock. You want hydra speed, so you order it up. Then the hydra den is destroyed and the queue hangs. Steamhammer solves that for zerg by canceling items whose prerequisites are missing, which is itself complicated and bug-prone. I think most remaining permanent deadlocks are caused by bugs in the strategy boss, the information manager, the production manager, or the building manager, or in their interactions with each other. Steamhammer tries to mitigate these by timing out and clearing the queue if nothing has been produced for too long, but that is not enough to save the game against a strong opponent.

A temporary production freeze is caused by waiting unnecessarily for a prerequisite to finish. For example, an old version of Steamhammer once froze frequently when it wanted a hive next, because it didn’t realize that it was still researching overlord speed. It had to wait until research finished before it could morph the hive, and in the meantime it was making no units and probably losing the game. The live version solves most issues like that, but it does have an unsolved production freeze that occurs while waiting for the spire (it sounds easy to solve, but I’m not finding it). Another example is: Suppose you want vulture speed and spider mines, and you made 2 machine shops to do the work, but 1 shop has been destroyed. No prerequisites are missing, so there is no deadlock, but you’ll end up researching the upgrades one after another instead of simultaneously, in the meantime making no units. Or even: You want something that requires gas next, so you wait for the gas to accumulate and produce nothing else even though you could make mineral units while waiting. I may add queue reordering to mitigate this, but the underlying issue remains.

Production freezes happen in other bots too. Watch the production tab in OpenBW. I’ve seen tscmoo suffer badly from temporary production freezes.

Software engineering is the solution. So far I’ve been fixing issues one by one. The underlying problem is that the software architecture is fragile. The right kind of fix is to redesign the production system in a way that is not prone to freezes. I don’t know what the redesign will look like, but some of its features are already visible from a distance. For example, I expect it will take into account low-level details like “which building will do this research?” before ordering the research; currently, the details are left to ProductionManager after the order is made, leaving room for slippage.

Anyway, my plans are always changing. This month I am on opponent modeling. After that, I plan to work on the mutalisk control that I’ve always promised. A new macro manager and re-architected production would be a logical task after that, especially since it would improve play for all races. At the rate I’ve been going, I may or may not get to it this year.

Trackbacks

No Trackbacks

Comments

Arrak on :

I've had some thoughts on that. Production in UAB right now works kind of like a bunch of pipeline stages, with potentially many frames in between the action being ordered and the action being completed. I think a fix would involve the error handling being applied at each stage, to detect the error rigorously and as soon as possible -- I suspect some freezes occur at the building manager stage. Also, it would be convenient to remove unnecessary stages and figure out a way to centralize error detection (to avoid having to write the same code everywhere). Additionally, there should be some cases where the queue can push the first item down the queue, if the item is non-crucial and the requirement is under construction, although we can reserve the absolute minimum resources needed for it factoring in income. After all, blocking on a spore colony is quite silly. --- By the way, I think I've found the gas oscillation bug. I was getting suspicious after I'd simplified my gas conditions. Should be a quick fix: in handleGasWorkers, it will remove ALL workers off gas if any refinery has no depot. In the exact same frame, if collectGas is on, it will try adding back workers to the other refineries. The next frame, it repeats... causing the workers to get stuck until the refinery dies.

Jay Scott on :

1. There are definitely freezes related to the building manager. :-(

Jay Scott on :

2. Good catch on the gas bug! I knew it was in there somewhere, because it only happens when a refinery has no depot.

Jay Scott on :

3. That is exactly what I meant by reordering the queue. We had the same idea.

MicroDK on :

Ohh that is exactly the same gas bug I get... thanks!
Also, Why would you produce an item that can not be produced? If the requirements are not fulfilled it should not be put in the Q. Only if a requirement is lost before the production of the item was started we should take action like remove it or reorder the Q.

MicroDK on :

When we are in an opening we have a different problem of the same kind: When we encounter an item with its requirements not fulfilled will we go out of the opening or add the requirement and reorder the Q?

Jay Scott on :

Good question. I’ll take it step by step. The smarter the production system, the more decisions you can leave to it, and the more abstract the input can be. It’s a small step to add “I want a sunken and there is no creep colony, so I’ll start one.” By the time the bot reaches pro level, the input can be “3 hatch muta” and it is implicit that it will adjust details or change plans entirely if it needs to. In between are a lot of steps....

Jay Scott on :

Wow, was I ever sloppy when I added optional gas collection to HandleGasWorkers. Removing workers from gas at all refineries—at the wrong time—in a loop for each refinery. And yet I reread it more than once and did not see a problem. Sometimes the blind spots we develop are very dark. It's 100% obvious that the _collectGas test should be at the top, not inside the loop, and not hard to notice the primary bug, which is that the refinery-has-no-depot test was incorrectly lumped in with the this-is-a-refinery test. Let's see if I rewrote it correctly this time....

MicroDK on :

I have rewritten HandleGasWorkers so hopefully Microwave will not loose more games because of this bug. ;)

Jay Scott on :

Should I post my revised code? I don’t consider it fully tested, but it is incorrect in at least a couple fewer ways....

MicroDK on :

That would be a good idea, since this is a serious game loosing bug, even if it is not fully tested.

Joseph Huang on :

I have a replacement macro system where I specify how much of each UnitType I want, and it will build whatever it can. It also supports multiple units per frame and latency compensation off.

MicroDK on :

How do you deal with latency? Do you count resources manually?

Joseph Huang on :

I track UnitTypes of pending units.

jtolmar on :

I also have a hand-rolled macro system. I already manually count resources for other reasons, and to handle latency I only run production decisions every maxLatency frames. That means a zealot could be delayed by 3 frames, but that's a pretty small imperfection for how many potential bugs it prevents.

Joseph Huang on :

I use unordered map of unit to unittype so i know which larva are pending, so i can produce every frame.

jtolmar on :

That's interesting to know. When I switched my bot from Terran to Protoss it mostly worked without any hitches, but when I tried it with Zerg I got all sorts of duplicated units and buildings.

Roman Ring on :

Hello, any plans to switch to newly released SC2 API? UAlbertaBot is already (partially) ported https://github.com/davechurchill/commandcenter

(Sorry for the off-topic)

Jay Scott on :

I am sticking with Brood War.

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.