Skip to content
BurnySc2 edited this page Sep 11, 2018 · 17 revisions

Should I use the pysc2 or python-sc2 library?

If you plan on making scripted hardcoded bots, python-sc2 is simpler in its syntax.

If you want to make a machine learning/deep learning bot, pysc2 is probably the better choice since it uses the UI and feature layers (spatial interfaces).

How do I do <something>?

Feel free to take a look at the protoss/terran/zerg examples.

What do I have access to in the step() function?

You have access to:

  • all the basic BotAI class properties and functions listed here and here through self.<property_name> which contain basic functions that handle macromanagement,

  • all the game state variables through self.state.<variable_name> which contain data that can change each step,

  • all the game info variables through self._game_info.<variable_name> which contain static map and player related data,

  • all the game data variables through self._game_data.<variable_name> which contain static unit/ability/buff related data,

  • your units self.units and visible enemy units self.known_enemy_units which is a list-like object and contain units of type Unit. Both have properties and functions available.

Why does my bot behave differently in realtime=True vs realtime=False?

realtime=False will wait for your bot step to finish before confirming the next game loop.

realtime=True on the other hand will not wait and will strictly continue. So your bot will only have a fixed amount of time to complete its step before the next game loop is called, regardless if your bot step is finished or not. That means calculating placement locations using self.find_placement() or self.expand_now() may result in a delayed action.

This is all nice and good but where do I find better bot examples?

Bots that have been put on the Bot ladder can be found here:

Also the source code of bots from the ladder are sometimes publicly available.

The pip version seems to be outdated, how do I install the version from github?

The command to install from github is

pip install --upgrade git+https://github.com/Dentosal/python-sc2.git
Clone this wiki locally