TorchCraft: a Library for Machine Learning Research on Real-Time Strategy Games

Gabriel Synnaeve, Nantas Nardelli, Alex Auvolat, Soumith Chintala, Timothée Lacroix, Lin, Zeming, Florian Richoux, Nicolas Usunier

TL;DR

This paper introduces TorchCraft, a library designed to bridge the gap between the complex world of Real-Time Strategy (RTS) games like StarCraft and machine learning frameworks, specifically Torch. By providing a more accessible interface for controlling these games, TorchCraft aims to unlock their potential as a robust benchmark for AI research, pushing beyond simpler environments.

What Problem Does This Paper Address?

Deep learning has shown remarkable success in domains like image recognition and natural language processing, and more recently, in simpler game environments like Atari. However, applying these techniques to more complex, real-world-like problems, such as Real-Time Strategy (RTS) games, presents significant challenges. RTS games are characterized by:

  • High-dimensional, partially observable state spaces: Players don't see the entire map (fog of war), and the state includes numerous units with complex interactions.
  • Complex dynamics: Simultaneous actions, resource management, unit production, and strategic planning create a challenging environment.
  • Large action spaces: Controlling many units with diverse abilities requires sophisticated decision-making.

Existing research in RTS AI often relies on specialized planning algorithms or limited experimental setups. The authors argue that a more accessible interface is needed to allow machine learning researchers to leverage the richness of RTS games as a benchmark for developing more general AI capabilities.

Methods

TorchCraft acts as a bridge between the StarCraft: Brood War game engine and the Torch machine learning library. Its core mechanism involves dynamically injecting code into the game engine, which then acts as a server. This server:

  1. Sends game state: It extracts relevant information about the game state (units, positions, health, etc.) and sends it to a connected machine learning client.
  2. Receives commands: It takes actions (commands) from the machine learning client and translates them into instructions for the game.

TorchCraft offers two modes of operation:

  • Game-controlled: A DLL is injected that provides the game interface. The TorchCraft server runs for the duration of a match, requiring re-establishment of the connection for new matches. This mode makes it easy to set up multiple learning instances.
  • Game-attached: The DLL attaches to the game process and communicates via pipes. This automates control but currently limits the creation of multiple learning instances on the same operating system.

The library also provides helper functions for understanding StarCraft's specific rules and state representations, and allows for re-examination of game data from past replays.

Datasets

The paper does not introduce new datasets for training or evaluation. Instead, it leverages the existing gameplay data and the active AI research community surrounding StarCraft: Brood War. The availability of professional player data and annual AI competitions is highlighted as a key advantage of using StarCraft as a benchmark.

Key Insights and Ideas

  • RTS games as a crucial AI benchmark: The authors strongly advocate for RTS games as a valuable testing ground for AI, due to their complexity, partial observability, and dynamic nature, which more closely resemble real-world problems than simpler game environments.
  • Bridging the gap is essential: The success of deep learning in other domains highlights the need for tools that make complex environments like RTS games accessible to ML researchers.
  • Structured state representation is key: Beyond raw pixels, providing a structured representation of the game state (as detailed in Appendix A) is crucial for effective learning in RTS games, offering a richer input than what's typically used for Atari games.

Key Results

The paper primarily focuses on introducing the TorchCraft library and its design. It mentions that TorchCraft has already been used in reinforcement learning experiments on StarCraft, leading to results that are expected to be open-sourced and included within TorchCraft. Specific quantitative results from these experiments are not detailed in this white paper.

Limitations and Future Work

  • Game-attached mode limitations: The current game-attached mode makes it impossible to create multiple learning instances on the same guest OS.
  • Future work: The paper implies that the results from the reinforcement learning experiments will be made available, suggesting further research and development based on the TorchCraft library. The ongoing use of TorchCraft in research and its potential to foster more work in RTS AI are also implied future directions.

Summary updated

BibTeX
@inproceedings{synnaeve2018torchcraft,
  author = {Gabriel Synnaeve and Nantas Nardelli and Alex Auvolat and Soumith Chintala and Timothée Lacroix and Lin, Zeming and Florian Richoux and Nicolas Usunier},
  title = {{TorchCraft: a Library for Machine Learning Research on Real-Time Strategy Games}},
  booktitle = {HAL},
  year = {2018},
}
Figure