Scenic4RL: Programmatic Modeling and Generation of Reinforcement Learning Environments

Abdus Salam Azad, Edward Kim, Qiancheng Wu, Kimin Lee, Ion Stoica, Pieter Abbeel, Sanjit A. Seshia

Introduction

Deep reinforcement learning (RL) has achieved significant milestones in complex domains such as robotics and competitive gaming. However, the success of these agents is often contingent on the diversity and representativeness of their training environments. In high-dimensional, multi-agent settings like soccer, standard simulators often rely on fixed layouts or simplistic random generation, which fail to capture the nuanced interactive behaviors—such as defensive formations or coordinated passing plays—required for true mastery. This limitation leads to poor generalization and makes it difficult to systematically evaluate agent performance against specific edge cases or rules.

The Scenic4RL Framework

To address these challenges, we introduce Scenic4RL, a framework that interfaces the SCENIC scenario specification language with the Google Research Football (GRF) simulator. SCENIC is a domain-specific language designed for modeling spatial relationships and behaviors in a declarative, probabilistic manner.

By using SCENIC as a high-level orchestrator, researchers can precisely define the initial state distributions and the programmatic behaviors of non-RL agents (teammates and opponents). This allows for the creation of complex, realistic scenarios that go beyond the capabilities of standard random initialization.

Programmatic definition of player distributions and movement patterns using SCENIC.

Methodology and Benchmark

The Scenic4RL interface allows SCENIC programs to govern the GRF simulator, sampling initial states and defining hierarchical behaviors using try/interrupt blocks. We established a benchmark consisting of 32 realistic scenarios, including:

  • Mini-games: 13 focused tasks (e.g., "3vs2 Counterattack") for rapid iteration.
  • Generalized Test Sets: Variants of each scenario (e.g., mirrored fields or altered player distributions) to evaluate robustness.
  • Stochastic Policy Data: 8,000 demonstration samples generated via programmatic SCENIC policies to facilitate imitation learning.

Key Insights and Results

Our experiments highlight several critical advantages of programmatic environment generation:

Debugging and Fine-Tuning

Scenic4RL enables a "debugging" workflow for RL agents. When an agent fails in a specific 11v11 situation, researchers can recreate that failure mode in SCENIC and fine-tune the agent on mirrored or slightly varied versions of that scenario. In one instance, an agent's performance improved from a 0.1 goal difference to 0.67 after such targeted fine-tuning.

The Generalization Gap

We observed a significant performance drop when agents trained on specific offensive tasks were tested on generalized variants. For example, performance on a "Pass and Shoot" task dropped from ~0.6 to near zero, underscoring the severity of overfitting in narrow training distributions. Conversely, agents trained on defensive scenarios showed greater robustness, likely because defense naturally requires modeling broader state distributions.

Modeling complex offensive plays and interactive behaviors to test agent coordination.

Accelerating Training

By using SCENIC to encode soccer intuition into "semi-expert" programmatic policies, we generated demonstration data that significantly accelerated RL training. This approach allowed agents to solve scenarios that were previously unsolvable by standard PPO within 5 million timesteps.

Conclusion and Future Work

Scenic4RL demonstrates that programmatic modeling is a powerful tool for improving the robustness and evaluability of RL agents in complex domains. While the current interface introduces some computational overhead (~3x slowdown), future optimizations involving in-memory updates are expected to mitigate this. We aim to extend this approach to other real-time strategy environments to further bridge the gap between simulation and real-world complexity.

Summary updated

Abstract

The capability of reinforcement learning (RL) agent directly depends on the diversity of learning scenarios the environment generates and how closely it captures real-world situations. However, existing environments/simulators lack the support to systematically model distributions over initial states and transition dynamics. Furthermore, in complex domains such as soccer, the space of possible scenarios is infinite, which makes it impossible for one research group to provide a comprehensive set of scenarios to train, test, and benchmark RL algorithms. To address this issue, for the first time, we adopt an existing formal scenario specification language, SCENIC, to intuitively model and generate interactive scenarios. We interfaced SCENIC to Google Research Soccer environment to create a platform called SCENIC4RL. Using this platform, we provide a dataset consisting of 36 scenario programs encoded in SCENIC and demonstration data generated from a subset of them. We share our experimental results to show the effectiveness of our dataset and the platform to train, test, and benchmark RL algorithms. More importantly, we open-source our platform to enable RL community to collectively contribute to constructing a comprehensive set of scenarios.
BibTeX
@inproceedings{azad2022scenic,
  author = {Abdus Salam Azad and Edward Kim and Qiancheng Wu and Kimin Lee and Ion Stoica and Pieter Abbeel and Sanjit A. Seshia},
  title = {{Scenic4RL: Programmatic Modeling and Generation of Reinforcement Learning Environments}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i6.20549},
}
Figure