# What is a Win Probability Model and How Can We Build One in Starcraft 2?

During the most recent stream by DeepMind on their AlphaStar project we saw so many new and unique thing but one item I think most overlooked immediately jumped out to me, they had created a Win Probability model.

It is easy to overlook, it is that small graph on the right side titled "Outcome Prediction." When we move in we can see it a bit more clearly.

Small though it is, the power behind is wonderous. Let me start at the beginning so I may explain why the idea of Win Probability is something so important. My background is in traditional sports statistics and a major focus for research in many of them is based on applying historical data to help players and coaches make the most informed decision based on what has worked in the past. In basic terms we take the entire population of relavent games and see how those teams fared in the same situation. If one team is down by a large amount of points we may find only 7% of teams came back from that deficit. This is derived from a few factors, let me break them down real quick. I understand this may be outside the wheelhouse as it involves American football lexicon but please bear with me:

- Firstly Win Probability looks at which team is considered the stronger one, usually this is done through Vegas betting lines but other methods of strength measurement have been used
- Secondly it looks at the score deficit
- Thirdly it factors in items like field position, time remaining, distance to goal and other items

Once these are collected it reviews historical information to see how teams did within this circumstances. Each play a team makes either increases or decreases their chance of winning. By knowing what teams in the past did teams can try to maximize their play calls and adjust their decision making to try and score the most points. In relation to American football here is a Win Probability chart:

For each play of the game there is a win probability for each team and it also measures how that action impacted that win probability for each team.

While much of this doesn't apply directly to Starcraft there is a way to design a Win Probability model the same way (using historical data) but with different inputs. Now these inputs were discussed with a few people where we looked at what information best measured how a player was doing:

- We look at what player was considered the stronger one using Aligulac
- Next we look at a few typical measures of how a player is doing
- Supply differences with historical racial differences (Zerg having more supply for example)
- Upgrade research
- Workers
- Base count (again with racial specifics)
- Army Value

- Then we looked at other, less common measurements of if a player is doing well
- Map vision (a measurement of what percentage of a map the player can see)
- Creep spread for Zerg players (what percentage of the map is covered)
- Map specific racial win rates

So when we put all this together we are able to view the game from a lens where a player can slowly gain a lead through macro advantages or a huge leap through something like a timing attack or winning a key engagement. Let us put forward an example. This is based on a real Terran (Player 1) versus Zerg (Player 2) game from IEM Katowice. After a traditional opening the Terran fails to scout that the Zerg is planning a two-base Roach/Ravager all-in. Being ill-prepared for the attack he suffers heavy losses but starts a Banshee and manages to hold the all-in. With the Banshee around, the Terran macros up, pushes through the two-base Zerg and wins. If we watch this game there are points where each player had an advantage. You'd think when the Zerg broke the Terran wall things were in a tough spot but once a Banshee was produced the Terran's hope improved. With the all-in crushed the Zerg would be at a disadvantage going forward. What Win Probability does is graph that out.

That is just what the ever-talented Mina and I did in this theoretical Win Probability graph, show what a model might look like. Below you will see two lines, each representing a player with red representing the Terran or Player 1 while blue represents the Zerg or Player 2. As you hover over the graph key moments will be highlighted. Go to 3:00 to see the unscouted all-in begin from the Zerg and that advantage peaked at 4:10, shortly after breaking the Terran main base open. Move further along and you'll see the Terran get the Banshee out and hold the all-in. We can see things go south for the Zerg quickly as they lose the economic and tech advantage, leading to their eventual loss.

But we can even break a game into key events. Now in traditional Win Probability models, each event has an impact on the game to varying degrees; this win percentage change is called Win Probability Added. Big events that shift the game greatly are said to have a large Win Probability Added. If we review the last game we can pinpoint a few key events that have a Win Probability of 2% or more. Remember that Player 1 is the Terran player while Player 2 is the Zerg player.

We can see two large swing events around the 4:00 minute mark when the Terran wall fell but the Terran got a Banshee out which shut down the all-in. After that, there were no large Win Probabilty Added events due to the economic advantage already being lost by the Zerg but often small events can add up to a victory. If we overlay these key events onto the first graph we can see which moments had the greatest impact on how the game shaped up.

Graphs like these are useful for a few reasons, they let us measure what some of the biggest comebacks were or show us what games or matchups are more back and forth. We can look at what timings may work best or maybe see if the meta is actually yielding the most effective strategies. But as of today that is still a bit out of our reach. What I've built today was merely an example, not a model we can use over and over again. This is something I am still working on though and if DeepMind does not make their Win Probability model public, it may be the best we have.

Now in closing I did ask the AlphaStar team about their model in their AMA. They wouldn't make public what inputs go into their model. They did say they felt it would be a useful tool so their system may be coming at some point.

Traditional sports have been trying to optimize their plans and decision making with Win Probability for years. While we have a long way to go there is a lot of potential as a tool for both players and viewers. Going forward I will be looking at this topic more in terms of the benefits we can gain from a tool of this type as well as the process in creating one, both in more depth than I have here.

Also big thanks to Mina for giving me feedback on the article and the amazing visual work she did on the charts.