• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:24
CET 06:24
KST 14:24
  • 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 Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
BGE Stara Zagora 2026 announced11[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge2
StarCraft 2
General
BGE Stara Zagora 2026 announced SC: Evo Complete - Ranked Ladder OPEN ALPHA When will we find out if there are more tournament Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge
Tourneys
Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death
Brood War
General
BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ A cwal.gg Extension - Easily keep track of anyone Which season is the best in ASL? soO on: FanTaSy's Potential Return to StarCraft
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Nintendo Switch Thread The Perfect Game Stormgate/Frost Giant Megathread Beyond All Reason Should offensive tower rushing be viable in RTS games?
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 TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Things Aren’t Peaceful in Palestine Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2800 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
Australia2394 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 Ireland26155 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
Australia2394 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
Canada428 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 States10686 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
Hungary5221 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 States10686 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
Next event in 4h 36m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft505
RuFF_SC2 173
Nina 103
StarCraft: Brood War
Noble 24
Icarus 8
IntoTheRainbow 6
Dota 2
XaKoH 712
monkeys_forever492
NeuroSwarm184
Other Games
summit1g15360
ViBE61
Mew2King42
trigger1
Organizations
Other Games
gamesdonequick1488
Dota 2
PGL Dota 2 - Main Stream201
StarCraft: Brood War
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH138
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 32
• Diggity5
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift3833
• Rush1430
Other Games
• Scarra1243
Upcoming Events
Sparkling Tuna Cup
4h 36m
NightMare vs YoungYakov
Krystianer vs Classic
ByuN vs Shameless
SKillous vs Percival
WardiTV Korean Royale
6h 36m
Zoun vs SHIN
TBD vs Reynor
TBD vs herO
Solar vs TBD
BSL 21
14h 36m
Hawk vs Kyrie
spx vs Cross
Replay Cast
18h 36m
Wardi Open
1d 6h
Monday Night Weeklies
1d 11h
StarCraft2.fi
1d 11h
Replay Cast
1d 18h
Wardi Open
2 days
StarCraft2.fi
2 days
[ Show More ]
PiGosaur Monday
2 days
Wardi Open
3 days
StarCraft2.fi
3 days
Replay Cast
3 days
The PondCast
4 days
Replay Cast
4 days
Korean StarCraft League
5 days
CranKy Ducklings
6 days
SC Evo League
6 days
BSL 21
6 days
Sziky vs OyAji
Gypsy vs eOnzErG
Liquipedia Results

Completed

SOOP Univ League 2025
RSL Revival: Season 3
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
META Madness #9
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
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
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.