README

Bots keep ignoring the past

Drekken

Why hello Reader,

I like to be right. Cause who wants to be wrong? 🤣. But that leads to missed opportunities because I talk myself out of taking action, waiting for certainty.

And the exact same thing happens to my bot.

Remember when I talked to you about setting my bot up to predict cheese? Well, it works a good amount of times. But when it’s unsure, it delays making a decision until it’s too late.

We already know that writing endless IF statements for every edge case is a trap. We also know how critical it is to prepare for a rush early before lings are chewing on your wall. But what if the scout dies, or misses a signal? I have watched my bot wait for that perfect alignment and die before it acts.

But I figured out a way to increase the speed of the decision without sacrificing, and in fact enhancing, accuracy.

Think about how your spam filters work. They calculate odds by starting with a baseline of how much spam you usually get, then weigh new evidence like the word “crypto” to decide if an email belongs in the trash. That’s what’s called Bayes’ Theorem in action.

We want our bots to do the exact same thing with their decisions, whether that’s to defend a cheese or press an attack.

It starts with a baseline of the likelihood of something happening, and then updates it with every new signal of information.

When your scout sees an empty natural, it updates a running probability.

It seems so obvious to me looking back in retrospect, but the missing layer is mathematical context. The theorem is how you translate that gut feeling into bot policy.

This is the formula that makes it work:

P(H|E) = [P(E|H) * P(H)] / P(E)

But breaking that down for our SC2 Bot:

P(H) is your Prior. This is your baseline belief before you scout anything. Based on their race, MMR, the map, and past games you’ve played, what is the chance they are going to 12-pool?

P(E|H) is the Likelihood. You send a worker and see an empty natural at two minutes. If they actually were 12-pooling, how likely is it that the natural would be empty right now?

P(E) is the Normalizer. The total probability of seeing an empty natural across all possible strategies. It keeps the math grounded between 0 and 1.

P(H|E) is the Posterior. This is your updated belief. You fold the new signal into your starting baseline to get a new percentage.

Every new signal shifts that baseline. Your bot continuously updates its probability as new data arrives. It acts on the math, just like a spam filter tossing an email the moment the odds tip too high.

The biggest gains came from refactoring my heuristics to include a Bayesian filter that acts in between my bot’s observations and its decisions.

⌨️ Next Commit

Add a filter to one area where your bot makes decisions. Some candidates:

  • Deciding if it can win a fight
  • If it should attack the enemy
  • If the enemy is going to attack it
  • Whether the enemy is going to cheese
  • Which opening build is the best to choose?

​scipy.stats & pgmpy are great to use and pair well with scikit-learn for ML.

You’ll need to start collecting data from your past games to make this really sing, so start there.

​

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