Information
# SMACv2 Documentation
# Introduction
SMACv2 is an update to [Whirl’s](https://whirl.cs.ox.ac.uk/) [Starcraft Multi-Agent Challenge](https://github.com/oxwhirl/smac), which is a benchmark for research in the field of cooperative multi-agent reinforcement learning. SMAC and SMACv2 both focus on decentralised micromanagement scenarios in [StarCraft II](https://starcraft2.com/en-gb/), rather than the full game. It makes use of Blizzard’s StarCraft II Machine Learning API as well as Deepmind’s PySC2. We hope that you will enjoy using SMACv2! More details about SMAC can be found in the [SMAC README](https://github.com/oxwhirl/smac/blob/master/README.md) as well as the [SMAC paper](https://arxiv.org/abs/1902.04043). **SMAC retains exactly the same API as SMAC so you should not need to change your algorithm code other than adjusting to the new observation and state size**.
If you encounter difficulties using SMACv2, or have suggestions please raise an issue, or better yet, open a pull request!
The aim of this README is to answer some basic technical questions and to get people started with SMACv2. For a more scientific account of the work of developing the benchmark, please read [SMACv2 paper](https://arxiv.org/abs/2212.07489). Videos of learned policies are available on [our website](https://sites.google.com/view/smacv2).
# Differences To SMAC
SMACv2 makes three major changes to SMACv2: randomising start positions, randomising unit types, and changing the unit sight and attack ranges. These first two changes were motivated by the discovery that many maps in SMAC lack enough randomness to challenge contemporary MARL algorithms. The final change increases diversity among the different agents and brings the sight range in line with the true values in StarCraft. For more details on the motivation behind these changes, please check the accompanying paper, where these are discussed in much more detail!
## Capability Config
All the procedurally generated content in SMACv2 is managed through the **Capability Config.** This describes what units are generated and in what positions. The presence of keys in this config tells SMACv2 that a certain environment component is generated or not. As an example, consider the below config:
\`\`\`yaml
capability_config:
n_units: 5
team_gen:
dist_type: "weighted_teams"
unit_types:
- "marine"
- "marauder"
- "medivac"
weights:
- 0.45
- 0.45
- 0.1
exception_unit_types:
- "medivac"
observe: True
start_positions:
dist_type: "surrounded_and_reflect"
p: 0.5
n_enemies: 5
map_x: 32
map_y: 32
\`\`\`
This config is the default config for the SMACv2 Terran scenarios. The \`start_positions\` key tells SMACv2 to randomly generate start positions. Similarly the \`team_gen\` key tells SMACv2 to randomly generate teams. The \`dist_type\` tells SMACv2 **how** to generate some content. For example, team generation has the key \`weighted_teams\` , where each unit type is spawned with a certain weight. In this case a Stalker is spawned with probability \`0.45\` for example. Don’t worry too much about the other options for now — they are distribution-specific.
All the distributions are implemented in the [distributions.py](https://github.com/oxwhirl/smacv2/blob/main/smac/env/starcraft2/distributions.py) file. We encourage users to contribute their own keys and distributions for procedurally generated content!
## Random Start Positions
Random start positions come in two different types. First, there is the \`surround\` type, where the allied units are spawned in the middle of the map, and surrounded by enemy units. An example is shown below.