Skip to content

Add RL/Gymnasium Integration #636

@EthanMBoos

Description

@EthanMBoos

Python bindings + Gymnasium wrapper for training RL agents in Scrimmage.

Why

The old OpenAI Gym integration was removed in Nov 2025 (commits 87ffbf1, e140f2a). Looking at what got deleted, I think the issue was embedding Python inside the C++ sim loop — Global Interpreter Lock acquisition every entity every timestep, messy control flow, etc.

Proposed approach

Flip the control: Python drives, C++ executes.

  • Use run_single_step() which already exists
  • Simple RLAutonomy plugin that's basically just a mailbox for actions
  • pybind11 bindings for SimControl/State/Contact
  • Gymnasium wrapper on top

The bindings would be opt-in (-DENABLE_RL_BINDINGS=ON), keeping the default build clean.

Scope

Starting small:

  • Single agent waypoint navigation
  • Maybe 1v1 pursuit evasion
  • SAC/TD3 (not PPO, need sample efficiency)

Multi-agent is a stretch goal.

What it'd look like

import gymnasium as gym
import scrimmage_gym
from stable_baselines3 import SAC

env = gym.make("Scrimmage-Waypoint-v0", mission="missions/waypoint.xml")
model = SAC("MlpPolicy", env)
model.learn(100_000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions