Speed Mining for SC2 AI: A Beginner’s Guide

Originally published at: Speed Mining for SC2 AIs: A Beginner’s Guide – VersusAI

Speed mining is one of those little tricks that can make a big difference in how well your bot performs in StarCraft II. It’s all about squeezing extra efficiency out of your workers by stopping them from needlessly slowing down. Get it right, and you’ll see up to a 10-12% boost in income—which means faster unit production, quicker tech upgrades, and an all-around stronger bot.

Python frameworks like Ares and Sharpy already include speed mining, but if you’re building a bot from scratch, mastering this technique is a must. Let’s break it down.

The Evolution of Speed Mining in AI Bots

Speed mining started with human players—Scarlett was the first to bring it into the SC2 AI scene, which sparked a wave of optimizations. Micromachine took a different route, figuring out how to speed up gas mining with bunker tricks, while other bot makers experimented with ways to push mineral mining efficiency to the next level.

Today, nearly every competitive SC2 bot uses some form of speed mining. If yours doesn’t, you’re already playing catch-up.


How Speed Mining Works

The Problem: Why Workers Slow Down

By default, SCVs, Drones, and Probes decelerate before reaching minerals or returning resources. This small delay adds up over time, lowering your income.

The Fix: Two-Point Commands

The trick is to override the deceleration by giving two movement commands:

  1. A move command that stops just before the mineral patch.
  2. A queued mining command immediately after.

Do the same when returning minerals, and you’ve got a faster, more efficient economy.

Key Considerations

  • Too Close? Your workers get stuck in the minerals and waste time.
  • Too Far? You lose the speed boost.
  • Map Differences? Some mineral patches require slight adjustments.

Pseudo-Code for Speed Mining Logic

Here’s a basic approach to implementing speed mining in your bot. This method calculates optimal worker positions and movement commands to maximize efficiency.

For each mineral patch, move a fixed distance (mining radius) from the patch toward the base to get an ideal target position.

FUNCTION ComputeSpeedMiningPositions(expansions, workerRadius):
    // Create a mapping from each mineral patch position to its target position.
    positionsMapping = empty map
    
    FOR EACH (base, resourceList) IN expansions:
        FOR EACH resource IN resourceList:
            // Calculate the ideal mining distance.
            miningRadius = resource.radius + workerRadius
            // Compute the target position by moving from the mineral patch towards the base.
            target = MovePointTowards(resource.position, base, miningRadius)
            
            positionsMapping[resource.position] = target
            
    RETURN positionsMapping

When a worker is actively mining (e.g., has only one active order), check if it should reposition to maximize efficiency.:

FUNCTION SpeedMineWorker(worker, speedMiningPositions):
    // Check if the worker is in speed mining mode (e.g., has exactly one order)
    IF worker.orderCount == 1 THEN
        target = NULL
        
        // If the worker is returning with resources (but not gas)
        IF worker.isReturning AND NOT worker.isCarryingGas THEN
            townhall = ClosestTownhallTo(worker)
            // Compute target near the townhall
            target = MovePointTowards(townhall.position, worker.position, townhall.radius + worker.radius)
        
        // If the worker is gathering minerals
        ELSE IF worker.isGathering THEN
            resource = GetResourceFromWorkerOrder(worker)
            // Use the computed speed mining position if it exists
            IF resource exists AND resource is a mineral field THEN
                target = speedMiningPositions[resource.position]
        
        // Validate target distance (for example, ensuring the target is not too close or too far)
        IF target EXISTS AND Distance(worker.position, target) is within desired range THEN
            MoveWorkerTo(worker, target)
            // Also ensure the worker continues to gather by re-issuing the gather command (or "smart" command)
            GatherResource(worker, resource)

-–

Next-Level Speed Mining Techniques

1. Turbo Mining (The Acceleration Trick)

Want to push speed mining even further? Some bots use worker collisions to instantly accelerate SCVs, skipping the slow ramp-up.

  • A stationary SCV acts as a launchpad.
  • The next SCV bumps into it and rockets off at full speed.
  • Harder to implement but shaves off extra frames.

For most bots, regular speed mining is more than enough and current tests have shown not much of a net benefit—but if you’re feeling creative, this technique is worth testing.

2. Bunker Mining (Gas Optimization)

If you’re playing Terran, bunker mining is a game-changer.

  • Instead of three SCVs per refinery, use a bunker to instantly drop them onto the gas geyser.
  • Saves two workers per gas geyser and frees them up for minerals.
  • Used by bots like Micromachine to gain an economic edge.
  • Works only on maps where natural gas geysers are positioned close enough for bunker transfer.

3. Mule Boosting (Fixing SC2’s Mule Bug)

Did you know SC2’s mules actually waste minerals?

  • Mules die before returning their 10th trip, meaning 25 minerals disappear.
  • Using collision tricks, bots can force the mule to return before it expires, saving resources.

4. Nidus/Prism Mining (Crazy Ideas That Might Work)

  • Zerg: Nidus Worms could be used to transport minerals back without a hatchery.
  • Protoss: Warp Prisms could (in theory) be used to teleport workers, but unloading delay kills efficiency.

Debugging & Troubleshooting Speed Mining

Common Issues & How to Fix Them

  • Workers Colliding? Too many workers using speed mining at once leads to crashes. Tweak the timing.
  • Inconsistent Results? Different maps have different angles—adjust dynamically.
  • Debugging Pain? Use replays in slow motion to catch bad movement patterns.

The Future of Speed Mining

Speed mining is already a standard technique, but that doesn’t mean it can’t be improved. The best bot makers keep experimenting—whether it’s refining gas mining, redistributing workers dynamically, or pushing micro optimizations to the limit.

If you’re working on an SC2 AI bot, adding speed mining is one of the best ways to boost your economy. Try it out, tweak it, and see how much efficiency you can gain.

Got a cool trick that makes your bot mine faster? Share it with the community!