Why hello [FIRST NAME GOES HERE],
The most important function of StarCraft 2 is managing the economy. If your bot does this well, it can go far without a lot of micro. So, how good is your bot at that?
I mean, sure, it can macro, but is it doing it well? Like a Diamond player or a Grand Master?
If you’re like me, you’ll want to know about the Spending Quotient (SQ), an equation that quantitatively measures macro skill, with higher numbers meaning better economic management.
|
🔁 In Case You Missed It
PiG_Bot DEBUT
The VersusAI Bot, PiG_Bot, has made its first competition debut on LaughNGamez’s channel. You can see its progress (and bugs) in action.
|
The equation for SQ is:
SQ(i,u) = 35(0.00137i – ln(u)) + 240
Where:
- i = average resource collection rate (minerals + gas, usually per minute)
- u = average unspent resources (float)
- The constants (35, 0.00137, +240) are just there to make the final number readable for humans
For humans, you can find these values on the post-game score screen. But for us bot makers, we can access the collection rate directly with:
|
bot.state.score.collection_rate_minerals + bot.state.score.collection_rate_vespene
|
To get the average, you’ll want to track your unused minerals and vespene throughout the game. I’ve found 60 samples over 60 seconds gives the most consistent results.
The output is usually a two-digit number—the higher, the better your bot’s economy.
Compare your bot:
- Bronze: ~60
- Diamond: ~75
- Master/GM: ~90+
Limitations
Keep in mind: SQ doesn’t work well for short or early games. It’s best used once your bot’s resource collection hits at least 600 minerals/gas per minute.
|
🛠️ In the Workshop
PiG_Bot got a full refactor on the combat module. Was able to solve (I think) the bug where my units were getting orphaned from attack commands. Turns out I was issuing 7 different commands to the same army per frame 😨. Remember kids, refactor is your friend
Botato recently added Reaper Micro, which has allowed it to take a game off of TyrT!
|
🗒️ ./run Notes:
Try implementing tracking to get SQ printed out at the end of a game using exponential moving averages:
- Samples every ~1 second: Records current bank and income rate (minimal overhead)
- Tracks throughout the game: Maintains running averages of unspent minerals/gas and income rates
- Calculates at game end: Applies the SQ formula 35(0.00137i – ln(u)) + 240 and outputs a detailed report
- Provides skill rating: Translates SQ score into league equivalents (GM/Master/Diamond/etc.)
This gives objective macro performance feedback independent of win/loss, helping identify whether the bot needs more production capacity or is resource-starved.
Sample Code
|
This is great for a printout in On_End to check your logs, but there are real-time opportunities too. You could have your bot track its SQ mid-match and react to fluctuations—if SQ starts dropping, something might be off in your production chain.
If you have ideas for implementing real-time SQ feedback, shoot a reply, I’d love to hear them.
|
May the Bugs Be Ever In your Favour🪲
|
|