code going to starcraft 2

Simple StarCraft 2 Python Bot Template To Get Started

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: Setup Environment

Here are a few things you’ll need to set up before getting started:

Prerequisites

Linux with Lutris?

Set these environment variables for best results (replace paths as needed):

export SC2PF=WineLinux
export SC2PATH="/home/YOUR_USERNAME/Games/battlenet/drive_c/Program Files (x86)/StarCraft II/"
export WINE="/home/YOUR_USERNAME/.local/share/lutris/runners/wine/YOUR_WINE_VERSION/bin/wine"

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 Repository

Open 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 Environment

To keep dependencies organized, set up a virtual environment:

Activate it:


venv\Scripts\activate # Windows
source venv/bin/activate # MacOS/Linux

Install Requirements

Now, install the bot’s required Python libraries:


pip install -r requirements.txt

Test Your Bot

Run your bot to check everything is working:

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.

code editor on bot screen

Step 3: Customizing Your Bot

Naming & Race Selection

Open config.py to specify your bot’s name and race (Terran, Zerg, Protoss, or Random), choose maps, and set opponent difficulty and race.

Adding Code

Put any new files or code modifications in the bot folder. This 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:


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.


Upgrade Path: Ares Framework

Want more advanced strategy and control? Upgrade to Ares-sc2 with one command:


python upgrade_to_ares.py

You’ll need to update your bot class and use super() calls in your hooks. Full guide in the repo README.



FAQs