• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:32
CET 16:32
KST 00:32
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !3Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win3Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
Did they add GM to 2v2? Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win ComeBackTV's documentary on Byun's Career ! RSL Revival - 2025 Season Finals Preview Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump
Tourneys
RSL Offline Finals Info - Dec 13 and 14! Master Swan Open (Global Bronze-Master 2) Winter Warp Gate Amateur Showdown #1: Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle How Rain Became ProGamer in Just 3 Months BGH Auto Balance -> http://bghmmr.eu/ [BSL21] RO8 Bracket & Prediction Contest BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] WB SEMIFINALS - Saturday 21:00 CET [BSL21] RO8 - Day 2 - Sunday 21:00 CET [ASL20] Grand Finals
Strategy
Game Theory for Starcraft Current Meta Simple Questions, Simple Answers Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile General RTS Discussion Thread Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
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
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI Russo-Ukrainian War Thread YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1964 users

Towards a good SC bot - P3 - Scouting

Blogs > imp42
Post a Reply
imp42
Profile Blog Joined November 2010
398 Posts
Last Edited: 2016-10-01 03:00:18
September 30 2016 23:02 GMT
#1
Towards a good StarCraft bot - Part 3 - "Scouting"

Summary: + Show Spoiler +
A guide on general scouting in 4 simple steps. Additionally, one step deals with basic machine learning and a final step with some very basic game theory to make the scouting pattern less predictable.


Scouting in 6 steps

An elegant algorithm that solves scouting pretty well, in 6 simple steps (Ok, maybe step 1 through 4 are simple while step 5 and 6 are a bit more advanced). It is assumed that you have decided when to scout and what unit(s) to use to scout.

Step 1: Heatmap “explored”
We create a heatmap containing for every tile (32x32 pixels) in the game the information whether the tile has been explored or not. The scouting unit is assigned the closest unexplored tile if either this tile is walkable and there exists a path from the scout to the tile, or the scout if flying.
Once any unit reaches a previously unexplored tile, the heatmap is updated to represent that the tile is now explored.
This simple algorithm will already make a scout explore the whole map.

the image below shows explored and unexplored regions.
[image loading]

Step 2: Heatmap “Key regions”
Instead of just assigning “true” for “explored” tiles and “false” for “not explored” tiles, we can identify some key regions of special interest and assign higher values to those regions.
In a first step, let us assign: 0: explored, 2: normal, 3: base location, 5 starting location
The scouting unit is assigned the closest tile of all tiles with the same highest value. This is all it takes to make the scout go explore possible starting locations first and then check expansion locations, before checking out everything else.

Key regions such as potential enemy starting locations have higher priority:
[image loading]

Step 3: aging heatmap
Instead of having static values, every value of the heatmap is regularly updated according to the newest information and then increased by a small amount. This way, explored tiles (whose values have been reset to 0) will slowly grow in importance up to the point where the scout decides to reexamine them.
Now we have created an algorithm which will let the scout explore the map endlessly, always going back to reexamine the spot that has been hidden in partial fog of war the longest.

the image below shows unexplored tiles growing in importance over time.
[image loading]

Step 4: weighted aging heatmap
A small improvement: instead of letting all tiles age with the same speed, we let tiles with high initial values (like the ones in key regions) faster. So the rate of growth is simply proportional to the initial value. This way, they are reexamined more frequently.

Step 5: machine-learning key regions
Instead of manually identifying key regions, we examine a set of replays and measure how long each tile was occupied by something interesting (usually an enemy building). This way, we are able to catch typical spots for proxies or hidden tech.

Note that the tile occupation values should be normalized after each analyzed replay as well as after completion of the learning session. Of course different sets can be learned for different match ups. Normalizing just means scaling down all values at the end of the game evenly to a range between e.g. 0 and 5. This way we can deal with longer and shorter games easily.
An advanced version slowly forgets what it has learned to account for shifting meta.

Step 6: playing with probabilities (Poker)
Brood War is at least to some extent a game of poker. If our opponent knows what algorithm we use to scout, then he will build proxies and hide tech at places he knows we won’t scout in a long time. Depending on our machine learning, we might or might not adjust the scouting pattern after game 1 in a best of 5. Either way, our strategy is easy to counter: If we don’t adjust, then abuse the same spot again. If we do adjust, then counter-adjust. So we have to become unpredictable.
In other words: we have to sometimes scout unlikely places first. This will make scouting less optimal, so we shouldn’t do it too often. How often we should do it is a game theory problem equivalent to the problem of how often to bluff in poker. Applying the solution from poker we would scout randomly, but according to the probabilities to find something interesting. That is, if machine learning establishes that region A is three times more likely to contain valuable information than region B, then we will still scout region B first with a probability of 25% = one out of four games.

Final comments:
In an actual implementation the exploring has to be implemented in a robust way. The scout could get stuck, get killed, or be unable to decide between two equally interesting locations. It could attempt to reach a location that is scoutable but not walkable or not manage to walk up a ramp, etc. etc.
The above algorithm should be viewed as a background algorithm to execute while nothing else happens. For example, once we find the enemy base it might make more sense to stick around as long as possible, going in circles around the base.

By the way: here is an example of the initial path of the scouting, recreated manually.
+ Show Spoiler +

As can be seen the scout checks out the enemy base first, then goes back to check for proxies in the own base, checks some other places on the map and then decides it's time to go back to the enemy base for a second look.
[image loading]


Credit:
The algorithm is inspired by how ants create paths via pheromones. Thanks to nepeta for valuable input and discussion on ant path finding!


*****
50 pts Copper League
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 01 2016 02:06 GMT
#2
Wow I think your algorithm is simple yet powerful. Thinking about your scouting algorithm makes me rethink my own scouting strategy. Although I do scout enemy base first, than proxies (identical to your algorithm) I always forget to recheck some areas.

I think you should give main attack paths a faster aging tile.
imp42
Profile Blog Joined November 2010
398 Posts
October 01 2016 02:46 GMT
#3
On October 01 2016 11:06 Jett.Jack.Alvir wrote:
I think you should give main attack paths a faster aging tile.

that's a good input. Actually I was thinking of including mobile units in the machine learned heat map as well, but later dropped the idea. Including mobile units would accomplish the goal of establishing what the main attack paths are.
Then they will automatically be interpreted as a key tiles and hence age faster.

The whole thing then works much like ant path finding, which inspired me in the first place.

Going further down the road, giving a higher priority to shuttle/dropship/loaded overlord will establish common drop harass patterns.
50 pts Copper League
YokoKano
Profile Blog Joined July 2012
United States612 Posts
October 02 2016 01:05 GMT
#4
completely unrelated but it's cool how old games can actually be deconstructed in a way comprehensible to the casual audience.
IQ 155.905638752
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 02 2016 02:07 GMT
#5
speaking of scouting unlikely places, I recall a game of SC2 where herO proxied a stargate right beside the natural of his opponent (I don't recall opponent but I think he was Terran). It wasn't game ending, but his opponent only found it until after the Stargate was finished.

Sometimes a ballsy proxy goes undetected because our opponent would never think we are brazen enough to try something so outrageous.
YokoKano
Profile Blog Joined July 2012
United States612 Posts
October 02 2016 04:34 GMT
#6
yes, protoss is the real deal. the race is true to its namesake, especially in SC2. winning and losing is a question of intuition.

it would be interesting to see a human player adapt in an AI series. we have seen previously the human will not magic box like the AI. other elements of control will also be missing. surely the human will play the designer, but it seems to be a considerable disadvantage. the designer will know gamer patterns, but the human will only be discovering the designer's thoughts.
IQ 155.905638752
imp42
Profile Blog Joined November 2010
398 Posts
October 02 2016 04:44 GMT
#7
On October 02 2016 13:34 YokoKano wrote:
it would be interesting to see a human player adapt in an AI series. we have seen previously the human will not magic box like the AI. other elements of control will also be missing. surely the human will play the designer, but it seems to be a considerable disadvantage. the designer will know gamer patterns, but the human will only be discovering the designer's thoughts.

Human brains are incredibly good at inferring patterns (Too good actually, in many cases inferring patterns where there aren't any...). At the current state of the art humans are able to detect AI patterns after game 1 and conclude winning counter-strategies for the rest of the series.
50 pts Copper League
graNite
Profile Blog Joined December 2010
Germany4434 Posts
October 02 2016 06:32 GMT
#8
Does it make sense to also consider the speed of the scouting unit and the game state?

speed: if the bot has a quick unit, it can check for proxies and complete the whole scouting route faster, so the priorities could be assigned values that are lower. the other way round, if you have a really slow unit, the choice of what to prioritize is more meaningful and has a bigger impact.

game state: scouting for proxies has a bigger impact on the game in the early game. the longer the game goes on, base locations become more important, especially when you consider what areas to recheck.


What about scouting by holding a position? (I dont know about BW, but in SC2) you can place overlords on some spots just permanently check if the opponent has taken a base or is taking a certain route. Is this part of the algorithm? Do you think it should be?

Is it possible to adjust scouting the "heat" of the game state? What I mean by heat is the amount of action happening and the number of fights per time. If there is a permanent battle going on, scouting for additional bases is not as important as opposed to when both players macro up and noone attacks.
In a game of permanent action, the scouting unit might make the difference in the fight.
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
imp42
Profile Blog Joined November 2010
398 Posts
October 02 2016 16:11 GMT
#9
On October 02 2016 15:32 graNite wrote:
Does it make sense to also consider the speed of the scouting unit and the game state?

this absolutely makes sense. In my own implementation I adjusted the configurations for the worker scout. A slower unit would never be able to catch up on anything while a faster unit would re-examine the enemy base too early. It's a point I actually had not thought of, even though I do allow for any unit to potentially scout.


game state: scouting for proxies has a bigger impact on the game in the early game. the longer the game goes on, base locations become more important, especially when you consider what areas to recheck.

This is actually quite important, yes. The naive way of doing this is to create a heat map for every in-game time unit. For example, every 100 frames. In a 10-minute game this requires approximately 10*60*24 / 100 = 144 states, which can be stored in approx. 2304 KB of memory (128*128 tiles * 144 frames * 1 Byte).
A more sophisticated approach would detect "significant changes" during the learning phase and update the heat map only at those specific times in the game.


What about scouting by holding a position? (I dont know about BW, but in SC2) you can place overlords on some spots just permanently check if the opponent has taken a base or is taking a certain route. Is this part of the algorithm? Do you think it should be?

While it certainly is very important I do not think it should be part of the algorithm. I would devise a separate algorithm for permanent scouting balancing potential information gained against likelihood to get killed. In real games this mostly applies to overlords, observers, zerglings, and the occasional marine. It sounds like a good topic for a follow up post on scouting.


Is it possible to adjust scouting the "heat" of the game state? What I mean by heat is the amount of action happening and the number of fights per time. If there is a permanent battle going on, scouting for additional bases is not as important as opposed to when both players macro up and noone attacks.
In a game of permanent action, the scouting unit might make the difference in the fight.

It is possible, but I advice against it. Whether or not to scout should not be decided by the scouting algorithm, but by a higher level decision maker. In my case it is the overall game strategy deciding.

50 pts Copper League
nepeta
Profile Blog Joined May 2008
1872 Posts
October 02 2016 16:17 GMT
#10
Impressive, most impressive ^^
Broodwar AI :) http://sscaitournament.com http://www.starcraftai.com/wiki/Main_Page
YokoKano
Profile Blog Joined July 2012
United States612 Posts
October 03 2016 02:54 GMT
#11
hahahahahahaha the scouting unit might make the difference in the fight that's great
IQ 155.905638752
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 03 2016 03:27 GMT
#12
Wow that is some higher level of understanding. So if a higher level decision maker tells your bot to scout, what kind of cues are you going to use to initiate the scouting algorithm? I would assume part of it would be time based (e.g. @ 6:30 scout opponent base for tech path). That would mean you might need several different scouting algorithms depending on cues (e.g. scout for proxy vs. scout for hidden base vs. scout main attack path). Or will your aging heat map take care of the various cues to scout?

This sc bot is quite intriguing.
imp42
Profile Blog Joined November 2010
398 Posts
October 04 2016 12:48 GMT
#13
On October 03 2016 12:27 Jett.Jack.Alvir wrote:
Wow that is some higher level of understanding. So if a higher level decision maker tells your bot to scout, what kind of cues are you going to use to initiate the scouting algorithm? I would assume part of it would be time based (e.g. @ 6:30 scout opponent base for tech path).
This sc bot is quite intriguing.

Speaking in theory, the decision maker evaluates its need for information vs. the likelihood to obtain such information by scouting. Early game this is not required to be calculated in-game, since as long as the opponent is still covered in fog of war, there are only three variables: the map, your own build, and the enemy race. So we can create a lookup table offline.
In practice this just resolves to e.g. a @9-scout

That would mean you might need several different scouting algorithms depending on cues (e.g. scout for proxy vs. scout for hidden base vs. scout main attack path). Or will your aging heat map take care of the various cues to scout?

following the line that the higher-level decision maker determines the "when" and the scouting algorithm decides on the "how", this will be taken care of by the heat map.

Now imagine the following scenario:
The algorithm has been initialized with a machine learned heat map indicating a very low probability for proxies. The scout arrives at the enemy base and finds.. nothing (a clear indication for a proxy). Now it is up to the higher-level decision maker to decide on the appropriate reactions: e.g. abort fe, build defense, find the proxy. The "find the proxy" part is delegated back to the scouting algorithm, which could implement it by adjusting the values of the heat map.
This reactionary update is definitely material for a part 2 on scouting though

Finding hidden bases is done automatically by the algorithm. Imagine the algorithm as a background task. Whenever you have an idle unit, you can assign it to do some scouting.
50 pts Copper League
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 04 2016 18:45 GMT
#14
This is getting more and more intriguing. And more complex the longer I think about the possibilities.

So a cue is triggered by the decision maker to scout. Scouting routine is initiated and finds information that triggers more decisions by the learning machine. It will become a continuous cycle of cue/routine/feedback all with separate algorithms that work in tandem.

Fascinating! The interesting part is the AI learning process, and once it recognizes patterns certain routines can be eliminated for efficiency.
imp42
Profile Blog Joined November 2010
398 Posts
Last Edited: 2016-10-04 21:13:24
October 04 2016 21:07 GMT
#15
On October 05 2016 03:45 Jett.Jack.Alvir wrote:
So a cue is triggered by the decision maker to scout.

I would phrase it like this: "A cue triggers the decision maker to initiate the scouting routine"

Scouting routine is initiated and finds information that triggers more decisions by the learning machine. It will become a continuous cycle of cue/routine/feedback all with separate algorithms that work in tandem

Just to clarify: I do all the learning offline from replays. While in-game, the loop is as follows:

loop:
1. check all cues
2. react on cue
2.1. if cue requires scouting and we're currently not scouting: initiate scouting
3. scouting potentially creates more cues
4. repeat: back to step 1

So yes, there is a cue/routine/feedback cycle, but the feedback does only affect the decision maker and not the scouting routine while in-game. Once the game is over the scouting routine can be altered by updating the heat map with the new information from the replay.

Edit: you maybe referred to the potential in-game alteration of the heat map. Then it is correct: the feedback also can affect the scouting routine itself. But I don't consider this to be "learning", since it is only an ad-hoc adjustment. I haven't implemented this yet, by the way.

50 pts Copper League
Jett.Jack.Alvir
Profile Blog Joined August 2011
Canada2250 Posts
October 05 2016 01:05 GMT
#16
A cue triggers the decision maker to initiate the scouting routine

Very subtle but I see the difference.

This is really fascinating. Makes me think of playing SC2 again.
Please log in or register to reply.
Live Events Refresh
WardiTV 2025
13:00
Playoffs
herO vs SpiritLIVE!
Scarlett vs Gerald
Rogue vs Shameless
MaNa vs ShoWTimE
Nice vs Creator
WardiTV1414
ComeBackTV 677
TaKeTV 366
IndyStarCraft 232
Rex135
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko480
IndyStarCraft 232
Rex 135
ProTech54
BRAT_OK 43
DivinesiaTV 7
StarCraft: Brood War
Britney 35510
Sea 3928
Calm 2291
Mini 1053
Horang2 906
Larva 877
EffOrt 820
Soma 706
ZerO 503
GuemChi 407
[ Show more ]
Snow 372
firebathero 313
Stork 310
hero 248
Rush 219
Sharp 206
BeSt 137
PianO 118
Hyun 88
JYJ 56
Light 50
Pusan 47
sorry 38
Mind 38
Mong 36
Sea.KH 34
Killer 33
Movie 27
Aegong 22
soO 22
Terrorterran 22
scan(afreeca) 12
Shine 11
Dota 2
Gorgc6638
singsing4790
qojqva2589
Dendi1011
syndereN235
Counter-Strike
byalli1130
oskar137
markeloff131
Other Games
B2W.Neo1218
Beastyqt611
crisheroes359
Hui .339
mouzStarbuck168
QueenE88
Livibee74
DeMusliM57
Mew2King52
Trikslyr29
ZerO(Twitch)24
nookyyy 16
Organizations
StarCraft: Brood War
lovetv 7
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 6
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV588
League of Legends
• Nemesis2296
• TFBlade738
Upcoming Events
WardiTV 2025
19h 28m
ByuN vs TBD
Clem vs TBD
OSC
22h 28m
CranKy Ducklings
1d 18h
WardiTV 2025
1d 19h
SC Evo League
1d 20h
Ladder Legends
2 days
BSL 21
2 days
Sziky vs Dewalt
eOnzErG vs Cross
Sparkling Tuna Cup
2 days
Ladder Legends
3 days
BSL 21
3 days
StRyKeR vs TBD
Bonyth vs TBD
[ Show More ]
Replay Cast
3 days
Wardi Open
3 days
Monday Night Weeklies
4 days
WardiTV Invitational
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 1
WardiTV 2025
META Madness #9
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL Season 19: Qualifier 2
CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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 © 2025 TLnet. All Rights Reserved.