• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:23
CET 10:23
KST 18:23
  • 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
TL.net Map Contest #21: Winners9Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!33$5,000+ WardiTV 2025 Championship6[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win TL.net Map Contest #21: Winners RotterdaM "Serral is the GOAT, and it's not close" 5.0.15 Patch Balance Hotfix (2025-10-8) StarCraft, SC2, HotS, WC3, Returning to Blizzcon!
Tourneys
Constellation Cup - Main Event - Stellar Fest $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
[ASL20] Ask the mapmakers — Drop your questions BW General Discussion [BSL21] RO32 Group Stage BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review
Tourneys
[Megathread] Daily Proleagues [ASL20] Grand Finals [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Should offensive tower rushing be viable in RTS games? 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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1519 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 Ireland25995 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
Canada425 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 States10682 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 States10682 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 37m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 204
ProTech124
StarCraft: Brood War
Sea 6556
Zeus 781
Larva 521
actioN 512
Killer 377
Soma 178
ToSsGirL 98
NaDa 35
sorry 32
Hm[arnc] 17
[ Show more ]
NotJumperer 17
Sharp 14
Sacsri 12
Bale 11
HiyA 10
Dota 2
NeuroSwarm108
LuMiX1
League of Legends
JimRising 529
Reynor90
Counter-Strike
fl0m2159
Heroes of the Storm
Khaldor46
Other Games
summit1g17672
C9.Mang0382
XaKoH 116
Organizations
Other Games
gamesdonequick638
Counter-Strike
PGL140
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• LUISG 14
• Adnapsc2 13
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos2600
• Stunt622
Upcoming Events
CranKy Ducklings
37m
IPSL
8h 37m
dxtr13 vs OldBoy
Napoleon vs Doodle
LAN Event
8h 37m
Lambo vs Clem
Scarlett vs TriGGeR
ByuN vs TBD
Zoun vs TBD
BSL 21
10h 37m
Gosudark vs Kyrie
Gypsy vs OyAji
UltrA vs Radley
Dandy vs Ptak
Replay Cast
13h 37m
Sparkling Tuna Cup
1d
WardiTV Korean Royale
1d 2h
LAN Event
1d 5h
IPSL
1d 8h
JDConan vs WIZARD
WolFix vs Cross
BSL 21
1d 10h
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
[ Show More ]
Replay Cast
1d 23h
Wardi Open
2 days
WardiTV Korean Royale
3 days
Replay Cast
3 days
Kung Fu Cup
4 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
4 days
The PondCast
5 days
RSL Revival
5 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
5 days
WardiTV Korean Royale
5 days
RSL Revival
6 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 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.