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

TL;DR

This paper introduces Scenic4RL, a framework that uses the SCENIC scenario specification language to programmatically generate diverse, realistic training environments for Reinforcement Learning (RL) in complex real-time strategy settings like soccer. By bridging high-level programmatic control with the Google Research Football (GRF) simulator, the authors demonstrate how to improve agent generalization and incorporate domain knowledge through "semi-expert" programmatic policies.

What Problem Does This Paper Address?

Reinforcement Learning agents are only as good as the data they train on. In complex Real-Time Strategy (RTS) environments—like soccer—agents often struggle to generalize because simulators typically rely on random generation from a few fixed layouts. This leads to two major issues:

  1. Lack of Diversity: Randomly sampled scenarios often aren't "realistic" or challenging enough to prepare agents for the infinite variety of real-world interactions.
  2. Lack of Control: Researchers can't easily specify complex behaviors for non-RL agents (like teammates or opponents), making it hard to "debug" specific failure cases or test niche tactical scenarios.

Methods

The authors propose using SCENIC, a domain-specific, probabilistic programming language, to define scenarios. Unlike standard simulator scripts that require hand-coding coordinates, SCENIC uses an intuitive, English-like syntax to describe spatial relationships (e.g., ball ahead of ego by 0.1) and agent behaviors.

Key technical contributions include:

  • SCENIC-GRF Interface: A bridge that allows the SCENIC server to govern the Google Research Football simulator, sampling initial states and managing interactive behaviors in real-time.
  • Programmatic Behavior Modeling: Using try/interrupt blocks in SCENIC to create sophisticated, hierarchical behaviors for non-RL agents (e.g., an opponent that dribbles until a defender gets close, then attempts a pass).
  • Stochastic Programmatic Policies: Researchers can write "semi-expert" policies in SCENIC to generate high-quality demonstration data, which is then used to pre-train RL agents via imitation learning.
The SCENIC interface architecture allows for high-level control over the underlying GRF simulator.

Datasets

The authors introduced a new benchmark consisting of 32 realistic scenarios encoded in SCENIC. This includes:

  • 13 Mini-game Scenarios: Focused tasks like "Hard Crossing" or "3 vs 3 Cross from Side" designed for faster iteration.
  • Generalized Test Sets: For each training scenario, they created a "generalized" version (e.g., mirroring the field or changing player distributions) to rigorously test if the agent actually learned the underlying tactic or just memorized coordinates.
Figure 2: Examples of a new defense scenarios with specific assigned behaviors (a), a test scenario to assess generalization (b), and two full game scenarios (c,d) we used for training and testing. The RL team is yellow and the opponent, blue. The assigned opponent behaviors are highlighted with light blue arrows. Uniformly random distribution is assigned over a specific region for each player. These regions are highlighted boxes.

Key Insights and Ideas

  • Generalization is Brittle: Agents that performed excellently in training often failed completely on "mirrored" versions of the same scenario. This highlights a massive "overfitting" problem in current RL benchmarks.
  • SCENIC as a Debugger: The framework allows researchers to "unit test" their agents. If an agent fails a specific tactic, a researcher can program a SCENIC scenario to isolate that failure, fine-tune the agent there, and see immediate improvement.
  • Domain Knowledge is a Force Multiplier: Pure RL (like PPO) often fails on complex coordination tasks. By using SCENIC to write simple "semi-expert" rules and generating just 8,000 demonstration samples, the authors could train agents to solve scenarios that were previously "unsolvable" by pure RL.

Key Results

  • Generalization Gap: In offense scenarios, agents showed a significant performance drop when tested on generalized versions. For example, a "Pass and Shoot" agent with a ~0.6 goal difference in training dropped to near zero in testing.
  • Debugging Success: An RL agent trained on a full 11v11 game failed a specific "open teammate" test scenario (goal difference of 0.1). After fine-tuning on a mirrored version of that scenario for just 5M steps, its performance on the original failure case jumped to 0.67.
  • Training Acceleration: Using SCENIC-generated demonstration data for pre-training allowed agents to achieve high performance in difficult scenarios (like "11 vs GK") where standard PPO training barely made progress.
Comparison of PPO performance with and without SCENIC-generated demonstration data.

Limitations and Future Work

The primary limitation is computational overhead. Adding the SCENIC layer over the GRF simulator resulted in a 2.99x slowdown in simulation speed. This is largely due to the need to update Python scenario files and disk-access overhead for each episode.

Future work aims to:

  • Optimize the interface to reduce this overhead (e.g., avoiding disk-access).
  • Expand the library of behaviors and scenarios to create even more complex RTS benchmarks.
  • Apply the SCENIC-RL approach to other domains beyond soccer, such as autonomous driving or robotics.

Summary updated

Abstract

The capability of a reinforcement learning (RL) agent heavily depends on the diversity of the learning scenarios generated by the environment. Generation of diverse realistic scenarios is challenging for real-time strategy (RTS) environments. The RTS environments are characterized by intelligent entities/non-RL agents cooperating and competing with the RL agents with large state and action spaces over a long period of time, resulting in an infinite space of feasible, but not necessarily realistic, scenarios involving complex interaction among different RL and non-RL agents. Yet, most of the existing simulators rely on randomly generating the environments based on predefined settings/layouts and offer limited flexibility and control over the environment dynamics for researchers to generate diverse, realistic scenarios as per their demand. To address this issue, for the first time, we formally introduce the benefits of adopting an existing formal scenario specification language, SCENIC, to assist researchers to model and generate diverse scenarios in an RTS environment in a flexible, systematic, and programmatic manner. To showcase the benefits, we interfaced SCENIC to an existing RTS environment Google Research Football(GRF) simulator and introduced a benchmark consisting of 32 realistic scenarios, encoded in SCENIC, to train RL agents and testing their generalization capabilities. We also show how researchers/RL practitioners can incorporate their domain knowledge to expedite the training process by intuitively modeling stochastic programmatic policies with SCENIC.
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