archive by month
Skip to content

upgrade prices in Steamhammer

Today I solved a major cause of production freezes. Steamhammer did not understand that repeated upgrades increase in cost, and I didn’t register that BWAPI requires you to specify the level of upgrade to get the prices of upgrades above level 1. So if Steamhammer wanted to upgrade zerg carapace +2 (gas cost 225) and had 200 gas, then if gas collection was turned off it would never turn gas collection on. It concluded “the upgrade costs 150 gas so I have enough.” The upgrade sat in the queue waiting for enough gas to appear, and the gas never appeared.

I think it’s the most common permanent production freeze remaining in the live version 1.3.3. Most long-lasting production freezes happen when gas is turned off and stays off.

The fix is to add code to MacroAct::mineralPrice() and MacroAct::gasPrice(). I verified that all upgrade prices are fetched via MacroAct; prices that it fetches directly are always for units or buildings, which are constant price. I added this code to MacroAct::gasPrice() (and similarly for the mineral price):

	if (isUpgrade())
	{
		if (_upgradeType.maxRepeats() > 1 && BWAPI::Broodwar->self()->getUpgradeLevel(_upgradeType) > 0)
		{
			return _upgradeType.gasPrice(1 + BWAPI::Broodwar->self()->getUpgradeLevel(_upgradeType));
		}
		return _upgradeType.gasPrice();
	}

Finally! I didn’t trace all the consequences, but the fix probably corrects other bugs too.

Trackbacks

No Trackbacks

Comments

Jay Scott on :

This mostly affects zerg. The zerg strategy boss is aggressive about turning off gas collection when it thinks it doesn’t need the gas. Terran and protoss are allowed to turn off gas collection in the opening book, but except for that they don’t. (Terran and protoss wouldn’t benefit as much anyway, since they tend to have more workers per base.)

PurpleWaveJadien on :

WHEW. Finding bugs like that can be a HUGE relief!

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.