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 Enviroment

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

Prerequisites

  1. Python – Recommended version: Python 3.7.x (though 3.8 should work too). Download Python here.
  2. Git – We’ll use Git for version control. Download Git here.
  3. StarCraft 2Windows: 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 the SC2PATH
    environment variable to your SC2 install path.
  4. StarCraft 2 MapsDownload 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.

  1. 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.
  2. 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>
  3. Create a Virtual EnvironmentTo keep dependencies organized, set up a virtual environment:

    Activate it:


    venv\Scripts\activate # Windows
    source venv/bin/activate # MacOS/Linux
  4. Install RequirementsNow, install the bot’s required Python libraries:

    pip install -r requirements.txt
  5. Test Your BotRun 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 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.

Ready to Stop Grinding? Build A Stand out AI Project with Free Resources

Scroll to Top