README

Three ways to win before you fight

Drekken

Why hello Reader,

Your army walks across the map. Sees the enemy. And now it has about half a second to answer the most important question in the game.

Should I take this fight?

Get it right, you trade efficiently and snowball a lead. Get it wrong, your army disappears and the game’s over. Pro players develop a feel for this over thousands of hours. Your bot doesn’t have that luxury. It needs a system.

There are three ways to build one. Each one is smarter than the last.

Let’s break down where they break.

Method 1: Napkin Math

The simplest version. Add up your army’s supply or resource value. Compare it to theirs. Bigger number attacks.

This is where most bots start. Write a rule, test it, patch the edge case, write another rule. 50 lines of IF statements and your bot still walks into a baneling horde. The moment unit counters show up, it falls apart. 10 marines vs 4 banelings? The math says you win. The banelings disagree.

Rules are fast and readable, but they can’t account for what you haven’t seen yet. They fail by being brittle.

Method 2: Simulate It

This is what combat simulators do. Take the units on both sides, run a mock battle second by second. Health, DPS, range, damage bonuses, healing, focus fire. Frameworks like ARES use a Rust-powered sim that returns a verdict: win, loss, and by how much.

Way smarter than napkin math. Emphatic victory? Push now. Marginal? Maybe wait for reinforcements.

But here’s the thing. The sim runs a perfect fight in a vacuum. No choke points, high ground, kiting, storms and no blink micro. The sim says your stalkers lose to roaches but in reality, good micro wins that fight EZ.

The sim predicts the future but fails because it lacks context.

Method 3: Learn It

Same logistic regression I talked about before but applied to predicting based on past battle outcomes.

Steven Brown once showed how to do this using the same model on the channel. Marines vs marines, fed into scikit-learn. 90%+ accuracy. Marines vs zealots? 99%. The model found the patterns in the data without being told what to look for.

Too good to be true? ML needs data. Lots of it. And the model only knows matchups it’s been trained on. Throw a composition at it that it hasn’t seen and it’s guessing blind. It fails by being narrow.

So Which One Should You Use?

No single method covers everything.

The sim looks forward and ML looks backward. One predicts what should happen based on the units right now. The other predicts what usually happens based on every fight before this one. Together they cover each other’s blind spots.

Same principle from dealing with zerg rushes where ML and hand-tuned rules worked as partners for rush detection. The tools complement each other.

If your bot only has one way to answer “should I fight?” it’s making that decision with one eye closed.

Start mixing methods by building your own ML battle predictor 👇🏾

video preview

How To Predict StarCraft 2 Battle Outcomes Using Machine Learning

🛠️ Workshop.log

Since putting ML in PiG_Bot, its win rate against zerg rushes has improved by 10% 🥹. The training only started at 150 games, and just retrained the model now after 750 games. Unfortunately the speedling detection was broken, you can’t check if the enemy’s unit has a buff on it from the API so I had to check for enemy zerglings if their speed increased between positions.

One question that comes to my mind: what if the combat sim could generate the training data for the ML model? Thousands of simulated fights, labeled automatically, then the model learns exactly where the sim’s predictions break down against real outcomes. I’m going to explore that in the near term, what do you think?

May the Bugs Be Ever In your Favour🪲

Email Preference:
Unsubscribe | Update your profile | 600 1st Ave, Ste 330 PMB 92768, Seattle, WA 98104-2246