There are a number a libraries you can select to begin writing your bot. Click here to get started.
You can also play against publicly available bots for testing or personal amusement by using the following application. Developed by Cryptious for SC2ai, you can load bots from various sources (see Downloadable Bots). Follow the ReadMe for instructions and troubleshooting. May requirement additional setup for bots outside of your framework.
-- House Bots: Most of the house bots were originally written by Infy & Merfolk for testing their own bots. They have kindly donated them to the community for use in testing.
-- Authors: You can search bots by author and check if their bots are downloadable or by searching by Bots directly.
Starcraft 2 AI
-- You can find and check for downloadable bots within their links from home page or by recent matches
You can upload your bot to test against others in the AIArena client. On the sidebar in the AIArena homepage, select Upload New Bot or go here and fill in the form.
A standalone plugin for python SC2 api maintained by EladYaniv.
Bots can save files to a local
data folder and these files will persist between matches.
This is a good way to remember what worked and what didn't.
A unique ID for each opponent is provided as a way for bots to recognize opponents. The ID is specified when starting the bot as a command-line argument after a
bot.exe --OpponentId 29381a9a-d299-4fb6-b225-cd455c9cc38b
This ID can be saved in your bot's data folder if desired.
The targeted unit will gain the relevant buff.
e.g. for the Cyclone lock, it will gain the
LOCKON buff as is listed here: https://github.com/BurnySc2/python-sc2/blob/develop/sc2/ids/buff_id.py#L124
Copy-paste, as written by ImpulseCloud (Holtan) in the sc2ai discord, starting at this message: https://discordapp.com/channels/350289306763657218/350289306763657220/630252706023342100
To see how to get the fastest minerals: https://dke.maastrichtuniversity.nl/m.winands/documents/CIG2017_resourcegathering.pdf He made one for SC2 too also, and I made some improvements to it, but haven't made any stats visualization for it can get a 10% speedup doing sock-folding and a couple of other tricks
I gave up before publishing anything. I did work with @yanntm(YoBot) to try to merge them into his bot. You can see some of that in https://github.com/yanntm/YoBot/blob/master/HarvesterStrategy.cpp It does manual ReturnCargo and Harvest actions to avoid the builtin 4-5 frame delay after the actions are done before the next action is queued. It also takes advantage of the trick of "exiting" mineral-walk will 'bump' the workers away from each other due to collision-physics, so if you have two workers that are mineral-walking thru each other, you have them exit mineral-walk as they pass their center-points, and then they get 'pushed' in their path-directions faster. and then also the 'magic-spot' trick where you have the worker sprinting to a point right in front of the mineral, so it doesn't take 2-3 extra frames to slow down before reaching (if in 'Harvest' action)
the one problem is that since it exits mineral-walk often, it will get screwed up by units (yours or enemy) walking thru the mineral-line, so you'd want to check for non-mineral-workers closeby whenever exiting mineral-walk. oh, using these tricks, you can also get that last load from a MULE the speedups actually 'oversaturate' close-minerals with just 2 workers, so if you don't force-pair on the mineral, one of the two will eventually end up waiting too long and leave the mineral you can even saturate far-minerals with just 2 workers if you use 2 speedlings to push/escort the workers back and forth (like pushing a merging-archon) but that would get too-crowded to do for all workers, especially with the other tricks, there'd be too many collisions
but it would immensely speedup long-distance-mining, at speedling speed ( the push/escort only works if the pushed/escorted unit doesn't have a Move command tho)
In Romanticide Soupcatcher's Zoe has been able to gather 3975 minerals in 5 minutes (6720 frames) using 12 workers that's 12% more of the 3550 an idle bot would get: https://discord.com/channels/350289306763657218/350290846320427011/878162916560482345
Unfortunately, Blizzard's support for the Protobuf API and bot play seems to be nonexistent as of 2022. Consequently, although can still develop your bot against the latest build of the game, there are annoying quirks and bugs that make it better to test and build against an older version of the game: 4.10, a.k.a. Build 75689.
To stay up-to-date with the meta, we use custom maps (suffixed with
AIE) with the latest balance patches applied.
Known issues with newer versions of the game: - There are no Linux builds past Build 75689. Several attempts have been made to contact Blizzard to release a newer Linux build, but to no avail. - Multiplayer (Bot vs Bot) games have a tendency to get "desynced", especially in builds past 5.x. This results in both bots playing in alternate realities. On 5.0.10, around 80% of games may end up desynced, which is practically useless.
In short, just use Build 75689. Your chosen language's API should have a way to choose the version, but to launch an older build manually, use this command:
# Working directory must be here cd /c/path/to/Starcraft\ II/Support64 /c/path/to/Starcraft\ II/Versions/Base75689/SC2_x64.exe -listen 127.0.0.1 -port 8000 -displayMode 0 -dataVersion B89B5D6FA7CBF6452E721311BFBC6CB2 -windowwidth 500 -windowheight 300 -windowx 0 -windowy 0 -verbose
The main thing here is the
dataVersion - it must match the build. A mapping can be found here. https://github.com/ocraft/ocraft-s2client/blob/master/ocraft-s2client-protocol/src/main/resources/versions.json
A situation can occur in longer games, where your units appear to executing orders that are very old (even an hour of ingame time). This can result in units spamming move commands on the ground, moving to attack bases that no longer exist, workers spamming minerals that no longer exist, etc. The other bot will be playing normally, so you will probably lose the game.
The best known reason for this is that there is likely a queue of actions (per player) that eventually grows to an unsustainable size and takes a long time to resolve. It has been observed most commonly around 120k APM (although some have observed this issue at 60k APM). To avoid this, try to reduce your APM below the 120k mark.
Your bot's language probably uses the StableID (
C:/Users/[UserName]/Documents/StarCraft%20II/stableid.json) to generate an enum of Upgrades. However, if you are looking for a specific Upgrade, it may not actually have the ID you expect. This may result in you checking for existence of an upgrade that you will never have.
The following table is a partial mapping of some of the more unusual upgrade values, so you don't have to hunt for them yourself:
|ID||Enum Value||English-language name||Notes|
||Combat Shields||Do not use
||Weapon Refit||Yamato Cannon. Do not use
Another thing to consider is that the Query interface for Available Abilities returns the generalised ability name. So for example, if you are using Available Abilities to determine if your Engineering Bay can upgrade Infantry Weapons Level 2, you need to check that it can use the
RESEARCH_TERRAN_INFANTRY_WEAPONS (3698) ability, not