alkurbatov / suvorov-bot

Starcraft 2 rule-based bot capable to play for all races.
MIT License
18 stars 6 forks source link

Don't spam the training queue with zealots #32

Open alkurbatov opened 4 years ago

alkurbatov commented 4 years ago

Happens when we have open gates which report idleUnit event each turn.

ImpulseCloud commented 3 years ago

Currently, ChargelotPush::OnIdle caps the Zealots in the schedule at 8.

if (builder_->CountScheduledOrders(sc2::UNIT_TYPEID::PROTOSS_ZEALOT) >= 8)
        return;

Does this satisfy the "don't spam" issue?

I assume the WarpGates show as Idle because they have an ability cooldown instead of a Training order, so Builder tries to send a command and it fails, which triggers another OnIdle next turn.

ChargelotPush::OnIdle could be made smarter and ignore WarpGates on Cooldown. But then, if OnIdle is not called next turn, then the gates won't produce anything. We'd need a ChargelotPush::OnStep to check when Warpgates' cooldowns are done before scheduling another Zealot.

Or maybe the WarpGate OnIdle issue should be handled somehow in Cpp-Sc2 instead, so it only is triggered after warp-in cooldown is finished.

alkurbatov commented 3 years ago

No, it doesn’t. The problem with warp gates is that we don’t track cool downs so it is assumed that gates are not busy. Skipping turns is barely workaround which slowdown the spamming, but it still happens.

alkurbatov commented 3 years ago

As it was pointed out recently the good way would be to check availability of particular abilities, e.g. take whole list of warp gates, do the call and verify what we have in response.

m_unitsAbilities = m_bot.Query()->GetAbilitiesForUnits(units);