• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:22
CET 14:22
KST 22:22
  • 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
Clem wins HomeStory Cup 282HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5
Community News
Weekly Cups (Jan 26-Feb 1): herO, Clem, ByuN, Classic win2RSL Season 4 announced for March-April7Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8
StarCraft 2
General
HomeStory Cup 28 - Info & Preview Clem wins HomeStory Cup 28 Stellar Fest "01" Jersey Charity Auction StarCraft 2 Not at the Esports World Cup 2026 Weekly Cups (Jan 26-Feb 1): herO, Clem, ByuN, Classic win
Tourneys
HomeStory Cup 28 RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) StarCraft Evolution League (SC Evo Biweekly) $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)
Strategy
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 511 Temple of Rebirth The PondCast: SC2 News & Results Mutation # 510 Safety Violation Mutation # 509 Doomsday Report
Brood War
General
Can someone share very abbreviated BW cliffnotes? 2024 BoxeR's birthday message Liquipedia.net NEEDS editors for Brood War BSL Season 21 - Complete Results Bleak Future After Failed ProGaming Career
Tourneys
The Casual Games of the Week Thread [Megathread] Daily Proleagues Azhi's Colosseum - Season 2 Small VOD Thread 2.0
Strategy
Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
EVE Corporation Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Path of Exile Mobile Legends: Bang Bang
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 Vanilla Mini Mafia
Community
General
US Politics Mega-thread The Games Industry And ATVI Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread Canadian Politics Mega-thread
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Quickbooks Payroll Service Official Guide Quickbooks Customer Service Official Guide
TL Community
The Automated Ban List
Blogs
Play, Watch, Drink: Esports …
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1832 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 Invitational
12:00
Playoffs
MaxPax vs ByuNLIVE!
SHIN vs Classic
Creator vs Cure
WardiTV893
IndyStarCraft 192
Rex120
IntoTheiNu 11
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 192
SortOf 125
ProTech121
Rex 120
trigger 18
StarCraft: Brood War
Britney 48727
Killer 5210
Hyuk 2580
Sea 2481
Rain 1903
BeSt 1760
Bisu 1443
Horang2 1255
Flash 1176
Jaedong 745
[ Show more ]
Soma 364
Stork 346
Larva 333
actioN 268
Snow 230
Leta 222
firebathero 208
Shuttle 196
Last 192
Mini 164
Soulkey 134
Hyun 109
JYJ 108
Mind 87
hero 81
ToSsGirL 69
Rush 62
Aegong 55
JulyZerg 46
NotJumperer 46
Sharp 40
[sc1f]eonzerg 37
Liquid`Ret 32
sSak 28
IntoTheRainbow 24
Backho 23
Free 22
Icarus 21
sorry 21
zelot 18
Yoon 17
Terrorterran 12
GoRush 12
910 10
SilentControl 7
Purpose 7
HiyA 5
Dota 2
singsing2369
qojqva642
Dendi314
XcaliburYe110
Counter-Strike
zeus1279
Super Smash Bros
Mew2King397
Heroes of the Storm
Khaldor206
Other Games
B2W.Neo1454
Hui .240
crisheroes214
RotterdaM173
Pyrionflax153
hiko142
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• StrangeGG 21
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos4681
• Stunt1001
• TFBlade933
Upcoming Events
Replay Cast
10h 38m
RongYI Cup
1d 21h
herO vs Maru
uThermal 2v2 Circuit
2 days
Replay Cast
3 days
Wardi Open
3 days
Monday Night Weeklies
4 days
Sparkling Tuna Cup
4 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-02-04
HSC XXVIII
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
Nations Cup 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8

Upcoming

Escore Tournament S1: W7
Escore Tournament S1: W8
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
LiuLi Cup: 2025 Grand Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
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.