ProcGrid Traffic Gym¶
Procedurally Generated Grid-Based Traffic Gym (PGTG) is a Gymnasium-compliant, feature-rich, extensible, and customizable reinforcement learning benchmark. An agent must navigate procedurally generated tracks while managing momentum and coping with stochastic obstacles and the unpredictable behavior of other traffic participants.
Since every feature — map generation, traffic, obstacles, and the observation and reward functions — can be granularly enabled, disabled, and tuned, PGTG presents a single, unified benchmark for studying the challenges of deep reinforcement learning both in isolation and in combination:
- Exploration
Particularly long tracks yield sparse-reward tasks. Study inter-episode exploration on a fixed map, or intra-episode exploration on changing, procedurally-generated maps. Stochastic traffic supplies "fake" novelty that exploration methods must learn to identify as such.
- Safety
A decoupled reward/cost signal plus optional dense navigation cues let you isolate safety performance from the navigation problem, so constraint satisfaction can be measured accurately without confounding it with a hard exploration task.
- Generalization
Procedural tracks make distribution shift a first-class citizen: train on one distribution of map sizes, connectivity, or traffic and evaluate out-of-distribution.
- Customizable & Extensible
Swap in your own obstacles, traffic rules, driver profiles, tiles, and maps through a clean, easy-to-use API. Default content takes the same paths as custom ones, ensuring that functionalities transfer cleanly to any new extensions.
Why PGTG?¶
Established grid-driving benchmarks such as Racetrack abstract driving to navigating a static track. This simplicity limits their utility: static tracks encourage overfitting to positions and a specific map layout rather than generalizing over track features. The absence of other traffic prevents studying interaction with unpredictable agents, and uniform action noise leaves little room for safety-relevant decision making. More flexible frameworks, such as Minigrid, solely pose a navigation problem (without control) and provide only loose structures: each environment must be built from scratch, hurting comparability, and extensions require full Python-level implementations, fragmenting their API.
PGTG addresses these limitations in one Gymnasium-compatible package: procedurally generated tracks, configurable traffic with driver profiles, localized obstacles that mimic diverse road conditions, and a modular reward structure with optional subgoals.
Quick example¶
import gymnasium as gym
env = gym.make("pgtg-v5")
observation, info = env.reset(seed=42)
terminated = truncated = False
while not (terminated or truncated):
action = env.action_space.sample() # Sample a uniform action; replace by your agent
observation, reward, terminated, truncated, info = env.step(action)
print("Episode ended:", info["termination_reason"])
Where to next¶
- Install from PyPI or from source.
- Quickstart by manually stepping through PGTG, or by training and evaluating your first agent.
- Configure PGTG to your needs.
- Extend PGTG with your own obstacles, traffic rules, driver profiles, and tiles.
Citing PGTG¶
If you use PGTG in your research, please cite the accompanying paper. See Citation.
