• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:01
CET 16:01
KST 00:01
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool40Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Potential Updates Coming to the SC2 CN Server Weekly Cups (March 2-8): ByuN overcomes PvT block Weekly Cups (August 25-31): Clem's Last Straw? Weekly Cups (March 9-15): herO, Clem, ByuN win
Tourneys
World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026]
External Content
Mutation # 518 Radiation Zone The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death
Brood War
General
Soulkey's decision to leave C9 JaeDong's form before ASL BGH Auto Balance -> http://bghmmr.eu/ [ASL21] Ro24 Preview Pt1: New Chaos ASL21 General Discussion
Tourneys
[ASL21] Ro24 Group A [Megathread] Daily Proleagues ASL Season 21 LIVESTREAM with English Commentary [BSL22] Open Qualifiers & Ladder Tours
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
U4GM Tips Counter Enemy Gadgets Fast in Black Ops rsvsr How to Keep Reward Chains Rolling in Monopol u4gm What to Do First in MLB The Show 26 Spring
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1528 users

Towards a good SC bot - P4 - Planning (1/3)

Blogs > imp42
Post a Reply
imp42
Profile Blog Joined November 2010
398 Posts
October 23 2016 17:34 GMT
#1
Towards a good StarCraft bot - Part 4 - "Planning (1/3)"

Summary:
+ Show Spoiler +
Instead of trying to plan ahead in the full StarCraft game, we design a mini-game where planning ahead is easy. The complexity of the game is thereby moved down one layer of abstraction and divided into the two separate problems of finding a good translation between the real game state and the mini-game state, as well as finding good rules for the mini-game.


One of the problems with “solving StarCraft” is the fact that there are thousands of possible moves at any given time and there is only little time to decide what move to pick. So approaches that have been used successfully in Chess and Go cannot be transferred directly to StarCraft.
Either we have to come up with novel approaches to search enormous solution trees or we have to invent a new game with less moves!

What if StarCraft consisted of only four possible moves?

Let’s define a new game, with only four possible moves as follows:

a) Increase own economy
b) Increase own army
c) Decrease enemy army
d) Decrease enemy economy

Ok, that sounds very simple. But what are the rules of the game?

1) The game is turn-based. Each player gets to pick one action per turn, then a payment is made to both players.
2) The payment adds X to the player’s bank.
3) Action a) costs 1 unit of money and increases X by 1 for the acting player (X: income per turn)
4) Action b) costs 1 unit of money to increase army size by 1
5) Action c) The smaller army A1 is set to 0. The larger army A2 is set to SQRT(A2^2 – A1^2) (i.e. the square root of the difference of the squares of the army sizes)
6) Action d) can only be performed if army size > 0
---a. If enemy army = 0: decreases X by 2 for the enemy player
---b. If enemy army > 0: decreases X by 1 for the enemy player, costs 1 unit of army
7) A player wins the game if the enemy’s army and future economy is 0

That’s it. Now we have a new game with 7 simple rules and 4 simple moves. It sure sounds a lot more manageable for an automated solver.

The game state is given as [B1, A1, I1, B2, A2, I2] with the B’s being player’s bank, A’s being army sizes and the I’s being income per turn.

How would such a game play out?
Let’s consider the four moves of player 1 and the four answers by player 2 for each. It turns out that move D is illegal and move C does not make any sense, because there is no army to fight with. Hence, only actions A and B remain for the first turn.
[image loading]

After both players have completed their move, the payment is made. So if player 1 invests in army (move B) and player 2 invests in economy (move A), the result after the first move will be [1,1,1,2,0,2]
A first game state evaluation shows two symmetrical outcomes and two symmetrical outcomes.

Let’s look at the next turn! Now it already gets very interesting, because all four moves are possible.
For player 1:
[image loading]

The tree for the reactions of player 2 to the second move of player 1 gets quite big. For reference:
+ Show Spoiler +
[image loading]


We can now perform a second game state evaluation.

- Let us call a move “strictly inferior” for a player if the resulting game state is dominated by the other player.
- Let us also refer to a game state as “dominated by player 1” if B1+A1+I1 > B2+A2+I2 and B1>=B2, A1>=A2, I1>=I2 (i.e. he has more than the other player in total, and not less on any single variable).

It turns out that the resulting tree is not that big after all, because quite a few branches can be pruned. Grey states indicate an equal game; orange states show losing moves for player 1, yellow states show losing moves for player 2. This leaves us with only 5 states to examine further (the 5 white ones at the bottom level).
[image loading]
Remember: these are only the first two moves. It will be interesting to see how e.g. a greedy player (choosing action A too often) will be punished. The above process can be repeated for any number of moves, rowing the tree to further levels.
I have implemented a small script in Prolog, which is able to play this game by performing the mini-max algorithm on the search tree.

Discussion
The question whether this approach is any good when playing real StarCraft depends on two factors:

Factor 1: How well can a real game state be translated to such a simplified form?
For example, what value should we assign to A1, if player 1 has 5 marines and two siege tanks?

Factor 2: How well do the rules of the mini-game reflect the real rules of StarCraft?
The quadratic function of rule c) approximates marines-only battles quite well, but it is no good when playing with units that counter each other. Another quite obvious deficiency is the lack of representation of parallel production.

Still, this extremely reduced mini-game already shows basic concepts of “macro”, “rush”, “harass”, “low-eco games”, “high-eco games”, etc.
Outlook: The next steps involve some refinement of the rules and then learning a good translation from real game state to simplified game state. Such learning could be done by various means, neural networks being one of them.

Disclaimer
Yes, the mini-game shown here oversimplifies hugely. It is just a starting point. The goal is to design a mini-game that represents the necessary (and only the necessary!) information to successfully consult a bot in what higher-level plan to follow.

the graphs shown were created manually. A quick cross-check with the implemented script shows they are correct. Nevertheless, there could be typos.

Credits
Credits go to like-a-boss and the people at IRC ##prolog for their help with the Prolog script.







****
50 pts Copper League
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 24 2016 17:07 GMT
#2
Again this is incredibly fascinating stuff. Your process in developing the bot really simplifies the game, yet unearths a lot of nuances when you translate it back to the actual game.

So your mini-game doesn't take into account increasing tech. If you tried to do that, how would it affect your tree? Considering you can't 'decrease enemy tech' once it reaches completion, perhaps this decision has no positive affect until X turns later. Also, an option to 'decrease enemy tech' is available to your opponent before X turn occurs. As well, when X turn occurs and tech completes, how will this affect the army?

I also wonder how you translate all this considering fog of war. It seems in your mini-game all information is available to both players.

Essentially, you distill any game down to a few choices, which is really what SC is all about.

Do I build an army or economy? When I have an army, do I attack his army or attack his economy?
imp42
Profile Blog Joined November 2010
398 Posts
Last Edited: 2016-10-24 18:47:45
October 24 2016 18:44 GMT
#3
On October 25 2016 02:07 Jett.Jack.Alvir wrote:
Again this is incredibly fascinating stuff. Your process in developing the bot really simplifies the game, yet unearths a lot of nuances when you translate it back to the actual game.

So your mini-game doesn't take into account increasing tech. If you tried to do that, how would it affect your tree? Considering you can't 'decrease enemy tech' once it reaches completion, perhaps this decision has no positive affect until X turns later. Also, an option to 'decrease enemy tech' is available to your opponent before X turn occurs. As well, when X turn occurs and tech completes, how will this affect the army?


I see my approach as a kind of reverse-engineering of what constitutes the complexity of the game. So I start as simple as possible and then model additional features from there.

It is "relatively" easy to calculate the army size required for an upgrade to be worth it. Let's just do another wild simplification and state the cost of the infantry weapon level 1 upgrade as 200 minerals. That is 4 marines.
So I could either have the upgrades or 4 more marines. I.e. the upgrade is worth it's cost if it increases total damage (in the game!) by more than what 4 marines would produce.
The second factor that comes into play is the fact that if you decide _not_ to upgrade, this will affect you later in the game because you will always lag behind in upgrades. The rules of the game make it impossible to decide to delay the first upgrade but speed up the second one.
This leads me to believe that, for now, I can just assume both players upgrade at the same optimal time, such that they cancel each other out. Remember that any feature of the game is only relevant here, if it influences what move will be picked in the mini-game.


I also wonder how you translate all this considering fog of war. It seems in your mini-game all information is available to both players.

My post on economy showcased how you can calculate the production possibilities frontier of the opponent. That is, calculate what he could possibly have at a given moment in the game. Since I wrote that post I have increased the accuracy of the mineral income prediction to roughly +/- 100 minerals for the first 20'000 frames (that is 13 minutes into the game). This prediction accounts for less-economical builds in that it considers the loss of future income as a consequence of having an army earlier.
Of course, with fog of war the range of possibilities keeps growing to the point the calculation becomes useless (at the 13 minute mark the opponent could have basically anything). That is where scouting comes in. It greatly reduces the range of possibilities.
What you do next (which is the part I am working on right now) is to map game states in such a reduced range to simplified states, then you can calculate the appropriate answers for the different possibilities in the range.
Since it is a game of incomplete information, you will somehow have to determine which of the answers to the possible states you will pick. It may be the one that covers most possibilities, or the one that is most likely not to lose, etc.


Essentially, you distill any game down to a few choices, which is really what SC is all about.
Do I build an army or economy? When I have an army, do I attack his army or attack his economy?


yes! And I want to find out what variables are required to make such a choice. I am convinced you neither need the full game state nor is the mini-game enough. But now I am able to narrow down the answer from both sides.

PS: on a side note, I think I will soon be able to calculate a rough value of information in terms of minerals. Then I could evaluate the value and cost of scouting.
50 pts Copper League
YokoKano
Profile Blog Joined July 2012
United States612 Posts
October 24 2016 19:49 GMT
#4
lol. you should heat map the trees based on unit position. it might be possible a sight range overlord could canvass the whole map.
IQ 155.905638752
imp42
Profile Blog Joined November 2010
398 Posts
October 24 2016 21:03 GMT
#5
On October 25 2016 04:49 YokoKano wrote:
lol. you should heat map the trees based on unit position. it might be possible a sight range overlord could canvass the whole map.

I didn't quite get the idea/joke.

regarding unit position, my assumption is that the positions do not matter when evaluating what move to choose.
More precisely, the assumption states that unit position is not an independent variable. Rather it can be translated into an army advantage when translating real game state into simplified game state.
50 pts Copper League
YokoKano
Profile Blog Joined July 2012
United States612 Posts
Last Edited: 2016-10-24 22:46:05
October 24 2016 22:43 GMT
#6
On October 25 2016 06:03 imp42 wrote:
Show nested quote +
On October 25 2016 04:49 YokoKano wrote:
lol. you should heat map the trees based on unit position. it might be possible a sight range overlord could canvass the whole map.

I didn't quite get the idea/joke.

regarding unit position, my assumption is that the positions do not matter when evaluating what move to choose.
More precisely, the assumption states that unit position is not an independent variable. Rather it can be translated into an army advantage when translating real game state into simplified game state.


it sounds like a unique solution. All the marine data will be located at the marine. In SC2 terms army value will include point value of say 12 marines, point value ranging from base to greater. The sum will be the marines' absolute value in game terms.

Could you use a related rates solution to increase army or economy each turn? Since we are standardizing both values, we can just compare the derivative and take the greater (or lesser from enemy perspective).
IQ 155.905638752
imp42
Profile Blog Joined November 2010
398 Posts
Last Edited: 2016-10-25 05:25:10
October 25 2016 05:20 GMT
#7
On October 25 2016 07:43 YokoKano wrote:
it sounds like a unique solution. All the marine data will be located at the marine. In SC2 terms army value will include point value of say 12 marines, point value ranging from base to greater. The sum will be the marines' absolute value in game terms.

Keep in mind that having the marines together is much more important, since army power is a quadratic function of army size. So you would need a higher order function representing how spread out the units are (minimizing), then a second order function representing point value from base. Because the full interaction of variables tends to get rather complex it would probably be rather difficult to extract the relevant ones by manual analysis. Instead, it seems a neural net could be a better candidate to find a good translation. This is an approach I am currently discussing at #bwapi.


Could you use a related rates solution to increase army or economy each turn? Since we are standardizing both values, we can just compare the derivative and take the greater (or lesser from enemy perspective).

Ok, I think I understand (but I'm not a 100% sure). The reason I picked a search tree and actually play out the game rather than maximizing some two-dimensional function is because the value of variables depend on each other. So the function to maximize would necessarily have to include all game state variables (so we're already talking 6-dimensional function). If I managed to find such a function allowing me to predict a move via derivation then that function would quite certainly become obsolete as soon as I change the rules of the game or add more variables to the state (while the mini-max just minimaxes over the new rules, whatever they are). Maybe it is possible to find such a function automatically, but that is currently above my league.

So yes, I think I'm sacrificing run-time efficiency for generality and your solution could work for a specific mini-game.
50 pts Copper League
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 25 2016 17:35 GMT
#8
I know during my SC2 games, I never commit to a skirmish unless I think I have an advantage (either positional/size/unit type) or a goal (snipe particular unit/reduce his army size/distract him)

If I can't commit to a fight, my next choice is to expand (increase own economy) or harass (decrease opponent economy). Sometimes I can do both if my opponent gives me an opportunity, but most often not.

I keep this decision tree going until I either get impatient and just go yolo in one big battle, or I make a mistake and lose.

I think the hardest part of your mini-game is deciding whether you can fight army or not. In a real game, there are so many factors to take into consideration. Attacking his economy is almost always viable, because its incredibly difficult to secure all your resources. You will almsto always find something undefended.
YokoKano
Profile Blog Joined July 2012
United States612 Posts
October 25 2016 21:31 GMT
#9
Thinking down the road aways you should make sure all the solutions are Pareto optimal. You seem to be doing this but I cannot tell if some of the solutions are only temporarily dominated. It is possible some actions will need to be examined in continuum. If the bot does not commit to behavior on turn 5 or turn 6 it may not understand what is happening at turn 1.
IQ 155.905638752
nepeta
Profile Blog Joined May 2008
1872 Posts
October 29 2016 15:15 GMT
#10
I'm still impressed by the way you're doing things. Do put a paper up sometime, I'm sure many coders would benefit from it. Keep up the good work!
Broodwar AI :) http://sscaitournament.com http://www.starcraftai.com/wiki/Main_Page
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
Last Edited: 2016-11-05 05:50:43
November 05 2016 05:34 GMT
#11
I don't understand all of what you said YokoKano, but I do understand the point.

imp42, can your bot understand if at the end of a small battle, did it gain/lose resources relative to the opponent? Or who ended the skimirsh with a small advantage?

Games I have lost was because I misread the army size. If your bot makes a mistake in examining the situation, how will it know to keep trying the same solution or move to another? Or how will it know it made any mistake for that matter?
imp42
Profile Blog Joined November 2010
398 Posts
November 05 2016 06:19 GMT
#12
On November 05 2016 14:34 Jett.Jack.Alvir wrote:
imp42, can your bot understand if at the end of a small battle, did it gain/lose resources relative to the opponent? Or who ended the skimirsh with a small advantage?

Up to now, I have taken a more calculation-based approach to the game, simply because I thought it would make sense to limit the game space mathematically as much as possible before attempting to explore such a space. For a small battle this means that the bot evaluates whether it is worth fighting or it should escape at every frame by just comparing applied and received damage. Once the battle is over it does not have any notion of how well it did. However, dead enemy units do count towards the upper limit of what the enemy could still have.


Games I have lost was because I misread the army size. If your bot makes a mistake in examining the situation, how will it know to keep trying the same solution or move to another? Or how will it know it made any mistake for that matter?

At least early to mid-game the probability of misreading is reduced somewhat because I know what the opponent could possibly have. So if I just see 2 marines when he could have 10 I could be suspicious.

As of now it has no concept of "mistake". It can safely assume it will not under-estimate enemy army size as long as calculating the upper-bound is still computationally feasible (~20k frames). over-estimating can lead to missed opportunities, but is generally not really harmful (because it implies being ahead).
Currently, the only way not to repeat a bad engagement is via tracking of enemy units and their last known positions.
Certainly more elaborate evaluations are required once more than one unit type are involved.
50 pts Copper League
Please log in or register to reply.
Live Events Refresh
Wardi Open
12:00
#79
WardiTV831
OGKoka 127
Rex112
IntoTheiNu 16
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 227
ProTech161
Rex 112
Trikslyr19
MindelVK 8
StarCraft: Brood War
Calm 10842
Bisu 3941
Horang2 1592
Jaedong 1568
Shuttle 934
Larva 638
Hyuk 619
BeSt 564
Stork 481
Mini 460
[ Show more ]
Soma 378
Light 378
Leta 243
Rush 227
Snow 194
Backho 119
ggaemo 103
Pusan 97
PianO 61
Sea.KH 59
[sc1f]eonzerg 57
Dewaltoss 51
Shinee 51
ToSsGirL 34
Nal_rA 32
Shine 31
910 30
Movie 30
Free 24
Aegong 21
IntoTheRainbow 19
soO 19
zelot 19
Hm[arnc] 18
sorry 17
GoRush 17
ajuk12(nOOB) 17
Noble 14
Terrorterran 11
Dota 2
Gorgc6305
League of Legends
Reynor76
Counter-Strike
fl0m3791
Fnx 2207
byalli1578
shoxiejesuss820
kennyS494
Other Games
singsing2162
hiko807
B2W.Neo694
XBOCT467
Beastyqt411
Lowko405
Happy225
OGKoka 127
Sick80
Mew2King61
oskar54
Organizations
Dota 2
PGL Dota 2 - Main Stream42
StarCraft: Brood War
Kim Chul Min (afreeca) 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• StrangeGG 28
• poizon28 3
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV316
• lizZardDota2119
• Noizen38
League of Legends
• Nemesis2909
Upcoming Events
Monday Night Weeklies
1h 59m
Sparkling Tuna Cup
18h 59m
Afreeca Starleague
18h 59m
Soulkey vs Ample
JyJ vs sSak
Replay Cast
1d 17h
Afreeca Starleague
1d 18h
hero vs YSC
Larva vs Shine
Kung Fu Cup
1d 19h
Replay Cast
2 days
KCM Race Survival
2 days
The PondCast
2 days
WardiTV Team League
2 days
[ Show More ]
Replay Cast
3 days
WardiTV Team League
3 days
RSL Revival
4 days
Cure vs Zoun
herO vs Rogue
WardiTV Team League
4 days
Platinum Heroes Events
4 days
BSL
5 days
RSL Revival
5 days
ByuN vs Maru
MaxPax vs TriGGeR
WardiTV Team League
5 days
BSL
6 days
Replay Cast
6 days
Afreeca Starleague
6 days
Light vs Calm
Royal vs Mind
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2026-03-22
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
CSL Season 20: Qualifier 1
ASL Season 21
Acropolis #4 - TS6
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

2026 Changsha Offline CUP
CSL Season 20: Qualifier 2
CSL 2026 SPRING (S20)
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.