Simple StarCraft 2 Bot Template to Get Started


最近看到 Harstem 的人机大战视频,自己对星际脚本产生了兴趣,所以本文介绍了基于 Python 的简易脚本搭建。

You might be the kind of person who has watched an episode or two of ProBots and been like? “Man I want to make one of those but I don’t know where to start?” well, wonder no more excited Netizen! We’ve gathered together an easy bake bot template for you to download and get started with minimum fuss. This template on it’s own won’t win anything but its the perfect place to start!

You can go over to github and grab the template then follow the instructions below

Contribute to eschampstudio/python-sc2-bot-template development by creating an account on GitHub.

(shout outs to lladdy & Burny for putting this together)

Also leave a comment on things you liked or things we can improve on this kind of tutorial. We are planning on doing a video to go along side this tutorial so your feedback helps us out.

Tutorial: Starting a python-sc2 bot

Preparing your environment

First you will need to prepare your environment.


This tutorial recommends you use Python version 3.7.X because that’s what most bot authoring tools use.
However, Python 3.8 should also work with this tutorial.


This tutorial will use git for version control.

Starcraft 2

On Windows SC2 is installed through the app.
Linux users can either download the Blizzard SC2 Linux package here or, alternatively, set up via WINE using this lutris script.

SC2 should be installed in the default location. Otherwise (and for Linux) you might need to create the SC2PATH environment variable to point to the SC2 install location.

Starcraft 2 Maps

Download the Starcraft 2 Maps from here. For this tutorial you will at least need the ‘Melee’ pack. (Direct Download )
The maps must be copied into the root of the Starcraft 2 maps folder - default location: C:\Program Files (x86)\StarCraft II\Maps.

Creating your bot


Click the green Use this template button in Github (you got to be logged into see it)! to create your own copy of this bot.
Now, using Windows PowerShell clone your new repository to your local computer using git:

git clone <your_git_clone_repo_url_here>

cd into your bot directory:

cd <bot_folder_name_here>

Create and activate a virtual environment:

python -m venv venv
# and then...
venv\Scripts\activate # Windows
source venv/bin/activate # Mac OS / Linux

Install the bot’s Python requirements:

pip install -r requirements.txt

Test the bot is working by running it:

python ./

If all is well, you should see SC2 load and your bot start mining minerals.
You can close the SC2 window to stop your bot running.

Updating your bot

Bot name and race

Now you will want to name your bot and select its race.
You can specify both of these in the bot/ file, in the CompetitiveBot class.

Adding new code

As you add features to your bot make sure all your new code files are in the bot folder. This folder is included when creating the for upload to the bot ladders.

Competing with your bot

To compete with your bot, you will first need zip up your bot, ready for distribution.
You can do this using the script like so:


This will create the zip file publish\
You can then distribute this zip file to competitions.

Additional Resources

You may want to check out the bits of code series (Github)

There is a pretty cool Carrier video to check out (Github)