scmJS docs

Bringing a BWAPI bot

BWAPI is the library the StarCraft bot tournaments are played with: a bot is C++ code that BWAPI calls every frame inside StarCraft 1.16.1. Here BWAPI 4.4.0 runs beside the game as it does there, so a bot is told what it would be told in the real game and plays the way it plays in the tournaments. McRave and UAlbertaBot on the play page are built this way from their authors' repositories, with no change to their code.

A bot is built from its source into one .scmbot file, which the play page and scmjs bot both play. The build is the only step that differs from a JavaScript bot.

What plays and what does not#

You have Does it play?
The C++ source of an AI module for BWAPI 4.4.0: the usual kind, a DLL project whose code defines newAIModule Yes
The C++ source of a client program: an .exe with its own main that connects to BWAPI, as UAlbertaBot is Yes. The build writes the module around the bot's class
Only a compiled .dll or .exe No. A browser does not run Windows code, so the bot has to be built from its source
A bot in Java, Python or another language No. The toolchain compiles C++
Source written for another version of BWAPI It is compiled against BWAPI 4.4.0's headers, and plays if it compiles against them
A bot that uses BWEM or BWEB Yes. They come as source and are built with the bot
A bot that uses BWTA2 No. BWTA2 comes as a Windows library

Most bots were only ever compiled by Visual Studio, which takes some C++ that other compilers refuse. The toolchain reads the bot's Visual Studio project and compiles the code as Visual Studio would. What still does not compile it rewrites in a copy, and says which lines it changed; your files stay as they are.

Building it#

You need Docker, the scmjs command line, and the bot's source. In the bot's folder:

scmjs bot init      # scmbot.json, read from the bot's Visual Studio project
scmjs bot build     # out/<key>.scmbot

bot init finds the bot's Visual Studio project and writes scmbot.json from it: the sources, the include folders, the defines, and the libraries the bot links. Read it over, since it is a starting point. bot build writes out/<key>.scmbot. The first build downloads the toolchain, a Docker image of a few GB; after that a build takes seconds and compiles only the files that changed.

A build needs a licence file in the bot's folder (LICENSE, with any licence you choose). Its text goes into the .scmbot file and is shown with the bot, beside BWAPI's own.

With no bot yet, scmjs bot new writes a small one in C++ to start from: its workers mine, its base trains more, and it builds supply.

The toolchain has a guide of its own at github.com/scm-js/scmbot: every field of scmbot.json, what is done for code written for Visual Studio, client programs, and the toolchain without scmjs, as a Docker command. Building a bot in the command line guide has the commands' own details.

Playing it#

A .scmbot file is played like a JavaScript bot's file (running a bot):

What the bot writes to bwapi-data/write/ during a game is given back to it in bwapi-data/read/ at the start of the next: by the page, up to 1 MB a file and 8 MB a bot, and by the command line in the folder --data names.

In a mod's game BWAPI's types are the mod's: its prices, its tech tree, and its unit types past the game's 228. A bot written for the game's own units still runs there; one made for the mod is written against the mod's names, which scmjs mod header --bot writes as a C++ header (a bot for your mod).

What is different from Windows#

scmJS 0.18.0 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.