• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:16
CEST 12:16
KST 19:16
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL62Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event21Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Program: SC2 / XSplit / OBS Scene Switcher Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
RSL: Revival, a new crowdfunded tournament series WardiTV Mondays FEL Cracov 2025 (July 27) - $8000 live event Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL Practice Partners (Official) ASL20 Preliminary Maps SC uni coach streams logging into betting site
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 744 users

BWAPI, and an inside look into StarCraft's code

Forum Index > BW General
Post a Reply
1 2 Next All
Sonko
Profile Joined February 2019
154 Posts
Last Edited: 2019-11-14 14:46:20
October 18 2019 08:40 GMT
#1
Hi dear people of TL forums,

A while ago, I started working on Brood War bot development. During this endeavor, I decided to write a book about it - and one of the chapters of this will be dissecting the code of StarCraft itself. This is quite an undertaking, but I'm making progress with it. Don't let the title "Brood War API" fool you, if you're a gamer, you might still find it interesting!

Here are the posts I have so far. I plan to post updates in this forum in the future, as I publish the episodes:
(Last update: 2019-11-14)

Brood War API – The Comprehensive Guide (of time and space)
Brood War API – The Comprehensive Guide – Distances, high ground, and unit behavior
Brood War API – The Comprehensive Guide – Unit movement, and worker behavior
Brood War API – The Comprehensive Guide: Creating buildings, and everything about the creep
Brood War API – The Comprehensive Guide: Buildings, and placement
Brood War API – The Comprehensive Guide: Movement modifiers, and Terran units
Brood War API – The Comprehensive Guide: Terran units continued, and some Zerg ones


Feel free to ask questions, point out mistakes/typos! I have a pretty good plan how I want to proceed with the topics within the book, and I'd like to publish updates at least weekly.

Enjoy!
Sonko

A site about brood war AI: www.makingcomputerdothings.com
Turbovolver
Profile Blog Joined January 2009
Australia2393 Posts
October 18 2019 11:36 GMT
#2
Nice work! I had a skim through it and even that taught me some things. A question though, what is the deal with detectors and moving? I wasn't aware that moving had any effect on a detector's ability to detect? Or is this just about its "detection region" only being updated every so often, ala sight?
The original Bogus fan.
WombaT
Profile Blog Joined May 2010
Northern Ireland25036 Posts
October 18 2019 11:42 GMT
#3
Ah great, been looking for some light reading material!

Joking aside this is pretty cool, look forward to having a proper look later today.
'You'll always be the cuddly marsupial of my heart, despite the inherent flaws of your ancestry' - Squat
Sonko
Profile Joined February 2019
154 Posts
October 18 2019 11:51 GMT
#4
Thanks for the feedback!
. A question though, what is the deal with detectors and moving? I wasn't aware that moving had any effect on a detector's ability to detect?


I don't really get your question here Can you maybe quote the part that implies that?
A site about brood war AI: www.makingcomputerdothings.com
Turbovolver
Profile Blog Joined January 2009
Australia2393 Posts
Last Edited: 2019-10-18 13:05:20
October 18 2019 13:05 GMT
#5
[quote=Sonko]Detector: If the unit is immobile, it can detect cloaked units within its sight range. If it’ mobile, it’s not constant. Blinded, incomplete, or disabled units cannot detect, and neither do hallucinations.[/quote]
This was the text that I wasn't sure about. "If it's mobile, it's not constant".

I thought that meant moving units versus stopped units, but I'm guessing the distinction is between say, a missile turret and a science vessel? And you just mean that the region detected is not constant for a moving unit?

(which of course makes perfect sense)
The original Bogus fan.
Sonko
Profile Joined February 2019
154 Posts
October 18 2019 13:11 GMT
#6
Yes, you're correct Maybe I'll rephrase that to be more clear.
A site about brood war AI: www.makingcomputerdothings.com
tankgirl
Profile Blog Joined May 2016
Canada398 Posts
October 18 2019 21:21 GMT
#7
How did you get the SC source code?
https://tl.net/forum/brood-war/627255-progamer-settings
TL+ Member
Sonko
Profile Joined February 2019
154 Posts
October 18 2019 21:46 GMT
#8
The short answer is I didn't I use openBW, a decompiled source - see the first article
A site about brood war AI: www.makingcomputerdothings.com
TelecoM
Profile Blog Joined January 2010
United States10668 Posts
October 18 2019 23:25 GMT
#9
Wow this is really interesting stuff... thanks for sharing! The coding is crazy lol
AKA: TelecoM[WHITE] Protoss fighting
Sonko
Profile Joined February 2019
154 Posts
October 19 2019 10:09 GMT
#10
And the next part is here: About buildings, and unit placement. This has been one of the hardest to research so far. Enjoy, and don't hesitate to ask if anything is not clear!
https://makingcomputerdothings.com/brood-war-api-the-comprehensive-guide-buildings-and-placement/
A site about brood war AI: www.makingcomputerdothings.com
Freakling
Profile Joined October 2012
Germany1529 Posts
Last Edited: 2019-10-19 12:55:36
October 19 2019 12:41 GMT
#11
Hero defiler (Unclean One) also has a different collision box than a regular Defiler.

For presenting tile/subtile grids you should better use screenshots from SCMDraft with walkability flag overlay.

People less versed in the OpenBW code, or coding in general, would probably like it if you would explain variable types and other definitions a bit.

The switching into additional terrain flags (cover, terrain level) also comes a bit sudden. You probably should write a more elaborate introduction to terrain flags first (you brush on all of it a bit, but I don't think it is very comprendable without prior knowledge).

The relationship between walkability and buildability is actually… a bit complicated… (Partially) unwalkable, but buildable tiles have some very interesting and useful effects.
PVJ
Profile Blog Joined July 2012
Hungary5214 Posts
October 21 2019 00:03 GMT
#12
Very interesting keep up the good work!
The heart's eternal vow
TelecoM
Profile Blog Joined January 2010
United States10668 Posts
October 21 2019 02:53 GMT
#13
Does APM / speed of hand / latency / ping affect how units work / attack / move or is that all in my head?
AKA: TelecoM[WHITE] Protoss fighting
Sonko
Profile Joined February 2019
154 Posts
October 21 2019 09:03 GMT
#14
"Does APM / speed of hand / latency / ping affect how units work / attack / move or is that all in my head?"

Latency is something you have to compensate for at some point, if you develop an AI. Other than that, they do, but not in the code
A site about brood war AI: www.makingcomputerdothings.com
Sonko
Profile Joined February 2019
154 Posts
October 21 2019 11:48 GMT
#15
And I missed one post:
Creating buildings, and everything about the creep - nipicking/proofreading/questioning of the things are always welcome!
A site about brood war AI: www.makingcomputerdothings.com
Akio
Profile Blog Joined January 2019
Finland1838 Posts
October 21 2019 12:51 GMT
#16
I know close to nothing about coding but this is super interesting! Thanks for sharing
Mine gas, build tanks.
Sonko
Profile Joined February 2019
154 Posts
October 22 2019 21:33 GMT
#17
You're welcome Also, if you want to get into programming, this is a great project. Many students have walked that path before
A site about brood war AI: www.makingcomputerdothings.com
Sonko
Profile Joined February 2019
154 Posts
October 24 2019 09:42 GMT
#18
Thanks everyone for the feedback! I corrected a few minor things, and rephrased stuff. I plan to release the next article soon!
A site about brood war AI: www.makingcomputerdothings.com
[UoN]Sentinel
Profile Blog Joined November 2009
United States11320 Posts
October 26 2019 03:44 GMT
#19
Really enjoyed your series on molesting crabs and such, looking forward to your newest deep dive!
Нас зовет дух отцов, память старых бойцов, дух Москвы и твердыня Полтавы
Sonko
Profile Joined February 2019
154 Posts
October 27 2019 09:23 GMT
#20
And the next part is here. It's a little all over the place, I extended and revised some of the earlier parts, and added stuff here. Anyway, it's about movement modifiers, and code behind Terran units.

Read it here!
A site about brood war AI: www.makingcomputerdothings.com
1 2 Next All
Please log in or register to reply.
Live Events Refresh
RSL Revival
10:00
Season 1: Playoffs Day 4
Clem vs ClassicLIVE!
SHIN vs Cure
Tasteless793
Crank 758
ComeBackTV 436
Rex60
IntoTheiNu 52
3DClanTV 49
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 793
Crank 758
Rex 60
MindelVK 27
IndyStarCraft 26
EmSc Tv 17
StarCraft: Brood War
Sea 8525
Calm 4586
Rain 2860
Horang2 2063
Bisu 952
Hyuk 843
Jaedong 541
Leta 258
Shuttle 209
Soma 179
[ Show more ]
PianO 163
ToSsGirL 142
TY 132
EffOrt 130
ZerO 103
Killer 64
Hyun 60
Rush 60
Last 51
JulyZerg 42
HiyA 27
zelot 25
JYJ21
Movie 20
Free 19
NaDa 9
ajuk12(nOOB) 9
Sacsri 6
ivOry 4
Dota 2
XaKoH 704
XcaliburYe685
Fuzer 248
League of Legends
singsing510
JimRising 285
Counter-Strike
Stewie2K1977
x6flipin212
Heroes of the Storm
Khaldor268
Other Games
Happy508
crisheroes253
Pyrionflax224
ZerO(Twitch)25
Organizations
StarCraft 2
EmSc Tv 17
EmSc2Tv 17
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH319
• LUISG 27
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2302
Upcoming Events
FEL
1h 44m
WardiTV European League
1h 44m
BSL: ProLeague
7h 44m
Dewalt vs Bonyth
Replay Cast
1d 13h
Sparkling Tuna Cup
1d 23h
WardiTV European League
2 days
The PondCast
2 days
Replay Cast
3 days
RSL Revival
3 days
Replay Cast
4 days
[ Show More ]
RSL Revival
4 days
FEL
5 days
RSL Revival
5 days
FEL
6 days
FEL
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #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 © 2025 TLnet. All Rights Reserved.