If you’ve ever watched an episode of ProBots and thought, “I’d love to build a bot, but where do I even start?” then you’re in the right place. We’ve created an easy-to-use python bot template that will help you dive right into StarCraft 2 bot development.
While this template alone won’t take you to the finals, it’s the perfect launchpad to get you building, testing, and learning how to program a competitive StarCraft 2 bot.
Step 1: Setting Setup
Here are a few things you’ll need to set up before getting started:
Prerequisites
- Python – Recommended version: Python 3.7.x (though 3.8 should work too). Download Python here.
- Git – We’ll use Git for version control. Download Git here.
- StarCraft 2 – Windows: Install via the Battle.net app.
– Linux: Download the SC2 Linux package here or use WINE with this Lutris setup script.
– For custom install locations or Linux, you may need to set theSC2PATH
environment variable to your SC2 install path. - StarCraft 2 Maps – Download StarCraft 2 Maps here. For this tutorial, you need at least the ‘Melee’ pack. Copy the maps into the
Maps
folder of your SC2 installation (default path:C:\Program Files (x86)\StarCraft II\Maps
).
Step 2: Set Up Your Bot
Head over to our GitHub page and grab the bot template.
- Create a New Repository – On GitHub, click the green Use this template button (make sure you’re logged in) to create a personal copy of this bot repository.
- Clone Your RepositoryOpen a terminal or PowerShell window, and clone your new repo:
git clone <your_git_clone_repo_url_here>
cd <bot_folder_name_here>
- Create a Virtual EnvironmentTo keep dependencies organized, set up a virtual environment:
python -m venv venv
Activate it:
venv\Scripts\activate # Windows
source venv/bin/activate # MacOS/Linux
- Install RequirementsNow, install the bot’s required Python libraries:
pip install -r requirements.txt
- Test Your BotRun your bot to check everything is working:
python ./run.py
If everything is set up correctly, StarCraft 2 will open, and you’ll see your bot starting to mine minerals. You can close the SC2 window to stop your bot.
Step 3: Customizing Your Bot
Naming & Race Selection
Open bot/bot.py
, and look for the CompetitiveBot
class to specify your bot’s name and race (Terran, Zerg, or Protoss).
Adding Code
Place any new files or code modifications in the bot
folder. This folder structure is used when creating your bot’s zip file for ladder submission.
Step 4: Competing with Your Bot
When you’re ready to compete, zip up your bot for distribution. Use the following command to package it up:
python create_ladder_zip.py
This will create a bot.zip
file in the publish
folder. You can upload this file to ProBots competitions or the AI Arena Ladder.
Closing Throughts
This guide should set you up with all the basics! Want to stop reading about making a bot and start working on one, head over to our membership page!
Happy bot-building!