reacting to build order disruptions
The live version of Steamhammer, when playing terran or protoss, tries to recover from a disrupted build order using a method inherited from UAlbertaBot: When it loses a building or a worker, it throws away the now-broken production plan and calculates a new one from scratch, using BOSS.
It’s not a very effective method. Games against Stone show why. When Stone kills a worker in the opening with its SCV rush, BOSS usually calculates a plan that says “OK, let’s build some gateways/barracks and workers, and later we’ll get combat units.” Then Stone kills another worker, the build is interrupted again, and BOSS says “OK, let’s build some gateways/barracks....” Steamhammer protoss beats Stone reliably because its probes fight well, but it often ends up with several extra gateways before it can get a zealot out and turn the tide. Steamhammer terran rarely gets a marine out before Stone beats it.
Today I improved the reaction. I didn’t change things when a building is destroyed, because that might genuinely break the build. I thought: If a few workers are lost in the middle game, it’s no big deal, so we can ignore it. If many workers are lost in the middle game, the game is probably over, so we can ignore that too. But if a worker is lost in the opening, we can replace it, and try to stay as close as possible to the original opening.
The code is in ProductionManager::onUnitDestroy()
.
// If it's a worker or a building, it affects the production plan. if (unit->getType().isWorker() && !_outOfBook) { // We lost a worker in the opening. Replace it. // It helps if a small number of workers are killed. If many are killed, you're toast anyway. // Still, it's better than breaking out of the opening altogether. _queue.queueAsHighestPriority(unit->getType()); // If we have a gateway and no zealots, or a barracks and no marines, // consider making a military unit first. To, you know, stay alive and stuff. if (BWAPI::Broodwar->self()->getRace() == BWAPI::Races::Protoss) { if (UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Protoss_Gateway) > 0 && UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Protoss_Zealot) == 0 && (BWAPI::Broodwar->self()->minerals() >= 150 || UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Protoss_Probe) > 0)) { _queue.queueAsHighestPriority(BWAPI::UnitTypes::Protoss_Zealot); } } else if (BWAPI::Broodwar->self()->getRace() == BWAPI::Races::Terran) { if (UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Terran_Barracks) > 0 && UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Terran_Marine) == 0 && (BWAPI::Broodwar->self()->minerals() >= 100 || UnitUtil::GetCompletedUnitCount(BWAPI::UnitTypes::Terran_SCV) > 0)) { _queue.queueAsHighestPriority(BWAPI::UnitTypes::Terran_Marine); } } } else if (unit->getType().isBuilding()) { // We lost a building. It may be serious. Replan from scratch. goOutOfBook(); }
The main complication is that if several workers are lost, we don’t want to delay the production of combat units while replacing the workers. So if there are no zealots and we can safely make a zealot, we do; and the same for a marine. A more aggressive reaction might be better, but this is what I went with.
Steamhammer protoss now defeats Stone smoothly. You have to watch closely to see when it deviates from its opening book. I expected that Steamhammer terran would still lose, because it doesn’t know what to do when an SCV that is constructing a building comes under attack. In fact, terran puts up a much stronger fight than before and sometimes wins. The marines don’t fight efficiently, but if they accidentally build up a critical mass then they sweep the enemy SCVs away.
It’s hilarious to see Steamhammer tech up to academy while still struggling to clear its base of the SCV rush. In the picture, Steamhammer’s academy is almost finished but it can barely keep marines alive. Shortly after this, more marines came out, the marines happened to group together well, and the SCV rush was suddenly broken. I didn’t see it coming at all.
Comments
krasi0 on :
Jay Scott on :
krasi0 on :
Jay Scott on :
LetaBot on :
krasi0 on :
You say: "after CIG" which kinda implies that you are about to use those strategies during the CIG tournament and don't want the opponents to have time to prepare against them? :D