Skip to main content

A StarCraft II bot gym env library over python-sc2

This library provide python-sc2 as a gym environment. So you benefits both from the sc2.BotAI and gym.Env classes to train your bot using existing algorithms.

This library (currently) covers only the raw scripted interface. At this time I don't intend to add support for graphics-based interfaces.

Documentation

class Sc2Env(gym.Env)

def init(self, map, bot_race, get_opponents, **kwargs):

  • map str upper camel case name of an installed map (ex: KingsCoveLE)

  • bot_race str race of the bot (ex: Zerg)

  • get_opponents Callable the opponents of the bot

    • returns a list of AbstractPlayer (BotAI, Player...)
  • initializer Callable Called on start, must set BotAI.action_space and BotAI.observation_space. The defined spaces must inherit from gym.spaces.space.Space.

    example:

    '''python def initializer(bot): bot.action_space = gym.spaces.Box(5,10) bot.observation_space = gym.spaces.Box(3,11) '''

  • observer: async Callable Called on step takes a sc2.BotAI instance, must return an observation and a reward. An observation is a numpy.array matching the observation space and a reward is number.

  • actuator: async Callable Called on step, takes a sc2.BotAI instance and an action. An action is a numpy.array matching the action space. Used to run actions using in sc2.

  • **kwargs any sc2.run_game extra arguments

More on sc2.BotAI here.

Installation

By installing this library you agree to be bound by the terms of the AI and Machine Learning License.

You'll need Python 3.6 or newer.

pip3 install --user --upgrade sc2-env

You'll also need an StarCraft II executable. If you are running Windows or macOS, just install the normal SC2 from blizzard app. The free starter edition works too.. Linux users get the best experience by installing the Windows version of StarCraft II with Wine. Linux user can also use the Linux binary, but it's headless so you cannot actually see the game.

You probably want some maps too. Official map downloads are available from Blizzard/s2client-proto. Notice: the map files are to be extracted into subdirectories of the install-dir/Maps directory.

Running

After installing the library, a StarCraft II executable, and some maps, you're ready to get started. Look at the dummy bot example!

python3 examples/dummy_bot.py

If you installed StarCraft II on Linux with Wine, set the SC2PF environment variable to WineLinux:

SC2PF=WineLinux python3 examples/dummy_bot.py

Metadata

Release files for sc2-env 0.11.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sc2-env 0.11.1.2
File Size Uploaded
sc2-env-0.11.1.2.tar.gz 78.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sc2-env 0.11.1.2
File Interpreter ABI Platform
sc2_env-0.11.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 168.2 kB

Release files / sc2-env-0.11.1.2.tar.gz

Download URL sc2-env-0.11.1.2.tar.gz
Size 78.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7c09d990e965d9262aa47b12117187ab9bf7f77f5869f399ed774bdf0ae90484
BLAKE2b-256 checksum
How to use checksums
657729954ccd79868c61ee17fc551acf341c30175a17939401d30b72e87c2f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release files / sc2_env-0.11.1.2-py3-none-any.whl

Download URL sc2_env-0.11.1.2-py3-none-any.whl
Size 89.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed289b6cdb6d22e437a98eb6989ace605aef7a0a14492260b906851fe7b71a4b
BLAKE2b-256 checksum
How to use checksums
87842cb5795f110834009d75886e0df5076987ffc660dda2baefdf01acf8d229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.11.1.2 This release

2 release files

0.11.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page