A New Approach to Solving SMAC Task: Generating Decision Tree Code from Large Language Models

Yue Deng, Weiyu Ma, Yuxin Fan, Yin Zhang, Haifeng Zhang, Jian ZhaoarXiv 2024 · OpenReview

Abstract

StarCraft Multi-Agent Challenge (SMAC) has been one of the most commonly used experimental environments in multi-agent reinforcement learning (MARL), where the specific task is to control a set number of allied units to defeat enemy forces. Traditional MARL algorithms often require interacting with the environment for millions of steps to train a parametric model, of which the resulting policies are typically non-interpretable with weak transferability. In this paper, we introduce SMAC-R1 which is based on the Qwen2.5-7B-Base LLM distilled from DeepSeek-Coder-v2.5-236B. Similar to online reinforcement learning after behavior cloning in offline learning process, in our pipeline, agents leverage the DeepSeek LLM to generate decision tree code by providing task descriptions, and the agents are further self-reflected using feedback from the rewards provided by the environment. Based on that, we augment the generated scripts to fine-tune a small LLM, Qwen2.5-7B-Base, to distill the decision-making ability via Supervised Fine-Tuning (SFT) and enhance the script generation ability by the Group Relative Policy Optimization (GRPO) algorithm. We conduct experiments in the original 23 SMAC tasks and 10 newly-designed tasks to demonstrate that our method can produce high-quality, interpretable decision trees with minimal environmental exploration. Moreover, these scripts exhibit strong transferability, successfully applying to homogeneous SMAC environments without modification. We believe this approach offers a new direction for solving decision-making tasks and domain-specific LLM training pipelines in the future.

Introduction

Multi-Agent Reinforcement Learning (MARL) has seen significant success in benchmarks like the StarCraft Multi-Agent Challenge (SMAC). However, traditional approaches rely on black-box neural networks that suffer from three primary limitations: low exploration efficiency (requiring millions of steps), a lack of interpretability, and poor transferability across different unit counts or map configurations.

SMAC-R1 proposes a paradigm shift: treating Python code as the action space. By using Large Language Models (LLMs) to generate executable decision trees, the system produces "white-box" policies that are human-readable, easily debuggable, and inherently more transferable than fixed-weight neural networks.

Methodology: The Planner-Coder-Critic Framework

The core of SMAC-R1 is an iterative pipeline designed to translate high-level tactical reasoning into executable code.

The Planner-Coder-Critic framework for iterative decision tree generation.

The framework consists of three main components:

  1. Strategy Planner: Analyzes environment prompts (task, unit, and map information) to propose high-level strategies such as "Focus Fire" or "Tanking."
  2. Decision Tree Coder: Translates these strategies into Python scripts using the python-sc2 library.
  3. Critic: Executes the scripts in the StarCraft II environment. It provides feedback, including win rates and error logs, which the Coder uses to refine the scripts in subsequent iterations.

Model Distillation and Training

To move beyond reliance on massive teacher models like DeepSeek-Coder-V2.5-236B, the authors developed a distillation pipeline to train a more efficient student model, Qwen2.5-7B-Base.

The SMAC-R1 training pipeline involving data collection and multi-stage fine-tuning (SFT, DPO, GRPO).

The training process follows three stages:

  • Supervised Fine-Tuning (SFT): The model is trained on high-quality scripts generated by the teacher model and community-sourced data.
  • Direct Preference Optimization (DPO): Refines the model by comparing successful and unsuccessful script attempts.
  • Group Relative Policy Optimization (GRPO): An RL phase that aligns code generation with environment rewards, particularly effective for "super difficult" maps where standard optimization fails.

Experimental Results

The model was evaluated on the standard 23 SMAC tasks and 10 newly designed maps featuring diverse unit combinations and terrain.

Performance and Efficiency

SMAC-R1 achieved a 100% win rate on most standard SMAC maps. Crucially, it demonstrated extreme efficiency, often converging on a winning strategy in fewer than five rounds of iteration. This contrasts sharply with traditional MARL, which requires millions of environment interactions.

Interpretability and Transferability

Because the output is Python code, the strategies are fully interpretable. The model autonomously discovered advanced tactics like "kiting" and "focus fire." Furthermore, scripts generated for specific scenarios (e.g., 3 Stalkers vs. 4 Zealots) were successfully applied to larger-scale battles (e.g., 5 Stalkers vs. 6 Zealots) without any modification, demonstrating superior zero-shot transferability.

Conclusion

SMAC-R1 demonstrates that LLMs can effectively serve as decision-makers in complex multi-agent environments by generating interpretable code. While challenges remain in the most extreme tactical scenarios and API-specific dependencies, this "code-as-policy" approach offers a promising path for creating efficient, transparent, and transferable AI for real-time strategy and beyond.

Summary updated

BibTeX
@misc{deng2024new,
  author = {Yue Deng and Weiyu Ma and Yuxin Fan and Yin Zhang and Haifeng Zhang and Jian Zhao},
  title = {{A New Approach to Solving SMAC Task: Generating Decision Tree Code from Large Language Models}},
  year = {2024},
  eprint = {2410.16024},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.16024},
}
Figure