• 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 (2/3)

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

Robustness and Plan Repair

Summary:
+ Show Spoiler +

Plan Repair is the concept of adjusting the execution of a plan in case of events negatively impacting the outcome.

Robustness describes how well a given plan is able to execute its plan in a wide range of different situations and edge cases.

Planning and Plan Repair can be applied to a lower level task of constructing e.g. a factory as well as highest level strategy.


I had written a post about planning a while ago using Prolog, a general-purpose logic programming language. An AI bot should be able to accept a goal and then derive the required steps to achieve that goal. But what happens if there are obstacles and things don’t play out the way that was anticipated?

In terms of AI research, the problem is formulated as follows:

In dynamic environments agents deal with changing situations which may partially or entirely invalidate an executable plan. Plan repair techniques aim to solve problems where modifications in the initial or goal state occur in the plan. They attempt to identify where the problem is located and fix the affected part of the plan.

The underlying assumption is that it is more efficient to repair an existing plan than to re-plan from scratch when something goes wrong.
How does this relate to Brood War? Let’s examine a seemingly simple case: The construction of a factory. What could possibly go wrong when the goal is to construct a simple building?

Well, from the perspective of a bot, the following:

  • Not enough resources (mineral / gas) to build a factory
  • Tech tree requirements not fulfilled (existing barracks)
  • No worker available to build
  • No construction site available (not enough buildable tiles, e.g. on a weird map)
  • The worker gets stuck on its way to the construction site
  • The worker cannot reach the construction site because of obstacles (like own or enemy units standing in the way) and just moves back and forth in a loop
  • The resources aren’t available anymore by the time the worker reaches the construction site (unlike SC2, Brood War deducts the resource costs when construction is starting, not when the build command is given. The available resources can change while the worker moves to the site)
  • The chosen construction site is not visible (anymore)
  • The chosen construction site is not free anymore (due to own or enemy mobile units placed on it)
  • The worker gets killed before it can start construction
  • The worker gets killed after it starts construction but before the building is completed
  • The building gets destroyed while still under construction

Furthermore, the plan itself could change because something more urgent has come up and the building is not required anymore (important scout info or resources required to defend a rush, etc.)

As you can see, there are at least 12 realistic reasons why a construction can fail. All of them need to be addressed to guarantee a successful outcome of the plan. This is where a key concept comes into play: Plan robustness.

A plan is robust if it avoids most of the potentially disadvantageous situations and there exist meaningful plan repair strategies for the remaining situations. We can divide the 12 identified issues into two categories: Green: Avoid, Red: Repair

  • Not enough resources (mineral / gas) to build a factory
  • Tech tree requirements not fulfilled (existing barracks)
  • No worker available to build
  • No construction site available (not enough buildable tiles, e.g. on a weird map)
  • The worker gets stuck on its way to the construction site
  • The worker cannot reach the construction site because of obstacles (like own or enemy units standing in the way) and just moves back and forth in a loop
  • The resources aren’t available anymore by the time the worker reaches the construction site (unlike SC2, Brood War deducts the resource costs when construction is starting, not when the build command is given. The available resources can change while the worker moves to the site)
  • The chosen construction site is not visible (anymore)
  • The chosen construction site is not free anymore (due to own or enemy mobile units placed on it)
  • The worker gets killed before it can start construction
  • The worker gets killed after it starts construction but before the building is completed
  • The building gets destroyed while still under construction

The green issues can be dealt with by a plan that is robust to begin with. That is, we only attempt to build the factory if we do have the tech tree, resources and worker available. Also, we make sure to choose a construction site that is buildable and reachable. Once we know we want to build the factory we already reserve the required resources such that they are not available to be used for anything else until they are actually spent.

Green issues mostly require thoughtful programming and consideration of edge cases. Thereby we can prevent the issues from occurring already before we start executing the plan.

The red issues however cannot be avoided because they might occur outside of our control. Even with careful and robust planning we cannot avoid death of a worker due to attacking enemies or the game engine failing its path finding resulting in a stuck worker.

Red issues require detection and appropriate repair measures while the plan is executed. They are more challenging to address than green issues.

Let’s assume the worker gets killed on its way to the construction site. How do we deal with this? Just send another one? Choose a different construction site? What if the second one gets killed as well? Should we escort the worker with army units? What if we don’t have any army units?

Likely it’s too late to react when the worker is dead anyways. Instead we should probably react when it gets attacked?

Experienced humans can intuitively decide what issues are likely to occur and how to deal with them. If a drone attacks the SCV we know we can send another SCV to fend it off, but if confronted with 2 enemy zealots we wouldn’t do that.

Teaching the bot to plan repair

One way to teach a bot plan repair is to create a large number of rules in an attempt to deal with any situation imaginable. But of course, this is not interesting from an AI perspective, since we basically just hardcode human expertise. Much more interesting would be a system that finds such rules by itself. For example, it could take note of all events that occur in a game and attempt to associate them with plan failure over many games.

Simplified, it could reach the following conclusion:

- Sometimes, when a drone shows up, the plan fails
- If no drone shows up, the plan never fails

Now it could attempt to take random measures whenever a negatively connoted event occurs and again take note of the outcomes and reach the following conclusion:

- When a drone shows up and I halt construction the plan still fails
- When a drone shows up and I send an SCV to attack it sometimes the plan executes successfully
- If I not only send an SCV to attack, but also retreat the first SCV before it is killed and resume construction with the second one, then the plan almost always succeeds

It can also attempt to associate its own actions with negatively connoted events as follows:

- If I place my building towards the enemy a drone is more likely to show up (bad)
- If I place my building hidden in the back of my base a drone is less likely to show up (good)

This way it will learn to prevent bad events in the first place.

Taking it to the next level

The concept of plan and plan repair can be applied to all levels of strategy as well.

In the most extreme case, achieving the goal of the game can be formulated as a plan to walk over and destroy the enemy townhall (the game is over when one party has 0 buildings). Anything preventing the bot from doing this can be interpreted as an event negatively impacting the outcome, to be dealt with via plan repair:

- Enemy builds additional buildings? Adjust plan to destroy them as well
- Enemy builds buildings faster than I can destroy them? Train a larger army
- Enemy trains army to defend its buildings? Adjust plan to deal with army first, such that the buildings can be destroyed afterwards
- Enemy attacks my army before it can destroy the buildings? Create a sub-plan to fend off the enemy attack first before proceeding with the main plan

Further reading

Plan repair techniques are being researched in the field of artificial intelligence.
For example, this article provides a formal definition for the multi-agent plan repair problem:

Antonín Komenda, Peter Novák, Michal Pechoucek:
Decentralized Multi-agent Plan Repair in Dynamic Environments.


The following simple visualization is taken from
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.520.2647&rep=rep1&type=pdf

[image loading]

Disclaimer

Unlike other concepts described in this blog, I have not implemented or tested any of the above behavior yet. As of now, the approach is purely theoretical.

I am aware that the descriptions are very high-level.



*****
50 pts Copper League
-visnu-
Profile Joined April 2009
Australia149 Posts
October 23 2017 15:58 GMT
#2
Taking it to the next level is the way of life. I Might find some time to contribute.
skinnyrl
Profile Joined March 2010
Netherlands125 Posts
October 24 2017 15:04 GMT
#3
This looks so interesting
''Every advantage has it's disadvantage'' Johan Cruyf
imp42
Profile Blog Joined November 2010
398 Posts
October 25 2017 19:16 GMT
#4
On October 24 2017 00:58 -visnu- wrote:
Taking it to the next level is the way of life. I Might find some time to contribute.

Sounds interesting. I'm also looking for people to try out BWAPI4J and beta-test it. Just let me know...
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.