How to Get Started with StarCraft II Reinforcement Learning Examples

Jan 17, 2021 | Educational

Welcome to your exciting adventure into the world of reinforcement learning with StarCraft II! This guide will help you set up and train your own AI agents using popular libraries and tools from DeepMind, OpenAI, and Blizzard. Are you ready to dive in? Let’s get started!

Current Examples

One of the fun examples you can try is the CollectMineralShards environment using a Deep Q Network (DQN). It allows your AI to learn how to maximize its score by collecting mineral shards in a simulated StarCraft II environment.

Quick Start Guide

Follow these steps to get everything set up:

1. Get PySC2

The easiest way to get PySC2 is by using pip:

$ pip install git+https://github.com/deepmind/pysc2

You will also need to install the baselines library:

$ pip install git+https://github.com/openai/baselines

2. Install StarCraft II

For different operating systems, the installation process varies:

  • Mac / Windows: Purchase StarCraft II and install it. The Starter Edition will work too. You can find it here.
  • Linux: Follow Blizzard’s documentation to get the Linux version. By default, PySC2 expects the game to be located at ~/.StarCraftII.

3. Download Maps

Next, you’ll need to download the ladder maps and mini-games:

4. Train Your Agent!

Now you can start training your agents. Here’s how to do it:

$ python train_mineral_shards.py --algorithm=a2c

5. Enjoy Your Creation!

Finally, you can enjoy the results:

$ python enjoy_mineral_shards.py

4-1. Train with DQN

If you want to train using DQN, the command looks like this:

$ python train_mineral_shards.py --algorithm=deepq --prioritized=True --dueling=True --timesteps=2000000 --exploration_fraction=0.2

4-2. Train with A2C (A3C)

To train using the A2C algorithm, use this command:

$ python train_mineral_shards.py --algorithm=a2c --num_agents=2 --num_scripts=2 --timesteps=2000000

Understanding Training Parameters

Lets visualize training your AI agent as preparing a dish. You have various ingredients (parameters) to choose from to perfect your recipe:

  • Map: Think of this as the serving dish. It determines the setting in which your AI will operate.
  • Algorithm: Your chef’s specialty. You can choose either deepq or a2c, which defines how your AI will learn.
  • Timesteps: The number of ingredients you’re adding—more timesteps can lead to a richer experience.
  • Exploration Fraction: Just like allowing the chef to experiment, this fraction determines how much room your AI gets to explore new strategies.
  • Priority and Dueling: These are special techniques to enhance your chef’s skills. If you choose to use prioritized replay or a dueling network, your AI will have some fancy tools at its disposal!

Troubleshooting Tips

If you encounter issues while setting up, here are some troubleshooting steps:

  • Ensure that you have the correct version of Python and all required libraries installed.
  • Make sure your StarCraft II installation is set up in the expected directory.
  • If facing performance issues, consider adjusting your training parameters or running fewer agents.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Conclusion

With these steps, you’re well on your way to developing advanced AI agents in StarCraft II. The journey of machine learning is full of exploration and experimentation—so get creative and have fun!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox