Skip to main content

Procedurally Generated Game-Like RL Environments (Gymnasium port)

Project description

Procgen Gymnasium

A Gymnasium port of OpenAI's Procgen Benchmark — 16 procedurally-generated environments for Reinforcement Learning (RL) research.

[Original Paper] [Original Blog Post]

Procgen Environments

What is this?

This project modernises the original procgen package (which depends on the deprecated gym and unmaintained gym3 libraries) to work with Gymnasium (the maintained successor to OpenAI Gym) and Python 3.13+.

The C++ game code is unchanged — only the Python interface layer has been rewritten.

Key changes from the original

  • gym / gym3 replaced with gymnasium
  • Supports gymnasium.make() (single env) and gymnasium.make_vec() (vectorized)
  • Compatible with all standard Gymnasium wrappers
  • Python 3.13+ support
  • Managed with uv and pyproject.toml

Installation

pip install procgen-gym

Requirements: Python 3.13+ (64-bit).

Platform Architecture Status
Linux x86_64 Supported
Windows AMD64 Supported
macOS - Not supported

Quick Start

Single environment (standard Gymnasium API)

import gymnasium as gym
import procgen_gym  # registers environments

env = gym.make("procgen_gym/procgen-coinrun-v0")
obs, info = env.reset()

for _ in range(1000):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()

env.close()

Vectorized environment (native batched)

import gymnasium as gym
import numpy as np
import procgen_gym  # registers environments

env = gym.make_vec("procgen_gym/procgen-coinrun-v0", num_envs=16)
obs, info = env.reset()

for _ in range(1000):
    actions = np.array([env.action_space.sample() for _ in range(16)])
    obs, reward, terminated, truncated, info = env.step(actions)

env.close()

Direct instantiation

from procgen_gym import ProcgenEnv, ProcgenVecEnv

# Single environment
env = ProcgenEnv(env_name="coinrun")

# Vectorized environment (C++ level batching)
vec_env = ProcgenVecEnv(num_envs=16, env_name="coinrun")

Environments

All environments produce (64, 64, 3) RGB observations and use a Discrete(15) action space. See docs/environments/ for detailed per-environment documentation.

Screenshot Name Description
BigFish bigfish Eat smaller fish to grow, avoid larger fish
BossFight bossfight Dodge projectiles and destroy a boss starship
CaveFlyer caveflyer Navigate cave networks in an Asteroids-style ship
Chaser chaser Collect orbs in a maze while avoiding enemies (Pac-Man inspired)
Climber climber Climb platforms and collect stars while dodging enemies
CoinRun coinrun Platformer — reach the coin at the far right
DodgeBall dodgeball Navigate rooms and throw balls at enemies (Berzerk inspired)
FruitBot fruitbot Collect fruit, avoid non-fruit objects in a scrolling game
Heist heist Collect coloured keys to unlock doors and steal the gem
Jumper jumper Open-world platformer with double-jump to find the carrot
Leaper leaper Cross lanes of traffic and hop across river logs (Frogger inspired)
Maze maze Navigate a procedurally-generated maze to find cheese
Miner miner Dig through dirt, avoid falling boulders, collect diamonds (Boulder Dash inspired)
Ninja ninja Precision platformer with charged jumps and throwing stars
Plunder plunder Naval cannon combat — destroy enemies, spare friendlies
StarPilot starpilot Side-scrolling space shooter with targeting enemies

Environment Options

All options can be passed as keyword arguments to gym.make(), gym.make_vec(), or the ProcgenVecEnv constructor:

Option Default Description
num_levels 0 Number of unique levels (0 = unlimited)
start_level 0 Lowest seed used to generate levels
distribution_mode "hard" Level variant: "easy", "hard", "extreme", "memory", "exploration"
paint_vel_info False Paint player velocity info in top left corner
use_generated_assets False Use randomly generated assets instead of designed ones
use_backgrounds True Use designed backgrounds (False for pure black)
restrict_themes False Restrict to single asset theme
use_monochrome_assets False Use monochromatic rectangles instead of designed assets
center_agent True Center observations on the agent
use_sequential_levels False Don't end episode at level completion, continue to next
num_threads 4 Number of C++ threads for environment stepping
rand_seed Random Random seed for level generation
debug_mode 0 Debug flag passed through to C++ game code

Gymnasium Wrapper Compatibility

ProcgenVecEnv and ProcgenEnv are compatible with standard Gymnasium wrappers.

Vector wrappers (gymnasium.wrappers.vector)

Wrapper Compatible Notes
GrayscaleObservation Yes RGB to grayscale conversion
ResizeObservation Yes Resize 64x64 to any resolution
ReshapeObservation Yes Reshape observation arrays
RescaleObservation Yes Best used after DtypeObservation(float)
DtypeObservation Yes Convert uint8 to float32/float64
FlattenObservation Yes Flatten to 1D (12288,)
NormalizeObservation Yes Running mean/std normalisation
TransformObservation Yes Custom observation function
ClipReward Yes Bound rewards to a range
NormalizeReward Yes Normalise rewards via running stats
TransformReward Yes Custom reward function
TransformAction Yes Custom action function
RecordEpisodeStatistics Yes Track episode returns and lengths
RecordVideo Yes Requires render_mode="rgb_array" and moviepy
HumanRendering Yes Requires render_mode="rgb_array", pygame, and opencv
DictInfoToList Yes Convert info dict to list of dicts
ClipAction No Discrete action space (not Box)
RescaleAction No Discrete action space (not Box)
FilterObservation No Box observation space (not Dict)

Single-env wrappers (gymnasium.wrappers)

Wrapper Compatible Notes
FrameStackObservation Yes Stack N recent frames
DelayObservation Yes Add observation delay
TimeAwareObservation Yes Append time step to observation
TimeLimit Yes Truncate after N steps
MaxAndSkipObservation Yes Frame skipping with max pooling
StickyAction Yes Probabilistic action repeat
GrayscaleObservation Yes RGB to grayscale
ResizeObservation Yes Resize observations
RecordEpisodeStatistics Yes Episode tracking
RenderCollection Yes Collect rendered frames
AddRenderObservation Yes Add rendered frame to obs dict

State Save/Load

from procgen_gym import ProcgenVecEnv

env = ProcgenVecEnv(num_envs=1, env_name="coinrun")
env.reset()

# Save state
states = env.get_state()

# ... take some actions ...

# Restore state
env.set_state(states)

Interactive Play

procgen-interactive --env-name coinrun

Keys: arrow keys + Q, W, E, A, S, D for actions. Score is displayed on screen.

Building from Source

git clone https://github.com/Achronus/procgen-gymnasium.git
cd procgen-gymnasium
uv sync --extra test
uv run python -c "from procgen_gym import ProcgenVecEnv; env = ProcgenVecEnv(num_envs=1, env_name='coinrun'); print('OK'); env.close()"

The C++ code requires Qt5 for rendering. On Windows, install via vcpkg:

vcpkg install qt5-base:x64-windows
set PROCGEN_CMAKE_PREFIX_PATH=path/to/vcpkg_installed/x64-windows/share/cmake

Known Issues

These are inherited from the original procgen and kept for reproducibility:

  • bigfish — Player can occasionally become trapped along environment borders
  • caveflyer — ~0.5% of levels spawn the player next to an enemy (instant death)
  • jumper — ~7% of levels spawn the player on top of an enemy or goal (instant termination)
  • miner — Low probability of unsolvable configurations

Citation

@article{cobbe2019procgen,
  title={Leveraging Procedural Generation to Benchmark Reinforcement Learning},
  author={Cobbe, Karl and Hesse, Christopher and Hilton, Jacob and Schulman, John},
  journal={arXiv preprint arXiv:1912.01588},
  year={2019}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

procgen_gym-0.1.0.tar.gz (25.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

procgen_gym-0.1.0-cp313-cp313-win_amd64.whl (26.1 MB view details)

Uploaded CPython 3.13Windows x86-64

procgen_gym-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl (52.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

File details

Details for the file procgen_gym-0.1.0.tar.gz.

File metadata

  • Download URL: procgen_gym-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for procgen_gym-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99c0ba089371e4283ef5a7d0488ecf0c45c2955d217b3c5efdd54a24c6a1043b
MD5 f9483c81104e5ba2657f30d96db6d95a
BLAKE2b-256 c8a12a2a4a5ee3dba36b6ecf18aadc65a91d3b600c745c7fb1c536130227d55a

See more details on using hashes here.

File details

Details for the file procgen_gym-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for procgen_gym-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e74da902bd5aa1e8ba235992230c76e7c11d15abd234d12946c4365514189480
MD5 cb441699282adcdf1943231b9a63e6dd
BLAKE2b-256 d7521bfa05f904c8f7aa1ed835b34916ce10187e87e3625a6f6f32fa5d5eba67

See more details on using hashes here.

File details

Details for the file procgen_gym-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for procgen_gym-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de6608ae548a3542ab2c3db3dd70a495dc3fcef9a533bd29cb1ca88333066011
MD5 dc0b975aa73a16ea12f09fb2c5d80131
BLAKE2b-256 d9ab65789f5f3049a913e9412021567e8d3f9dcb026fa2220e7182d4cab18a34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page