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.
Comments
Jay Scott on :
PurpleWaveJadien on :