Wrapper architecture
PufferLib’s wrapper system consists of three main components:- Emulation wrappers - Convert Gymnasium and PettingZoo environments to the PufferEnv interface
- Preprocessing wrappers - Apply transformations like observation resizing and episode statistics
- Environment-specific wrappers - Handle unique requirements of specific environments
How wrappers integrate
The typical wrapper stack for an environment looks like this:- Vectorized interface - Batch dimension for observations, rewards, terminals
- In-place updates - Zero-copy buffer management
- Unified API - Same interface for single-agent and multi-agent environments
Available environment wrappers
PufferLib includes 36 environment integrations out of the box:Classic environments
- Atari - Arcade Learning Environment games (Breakout, Pong, etc.)
- Classic Control - CartPole, MountainCar, Acrobot, Pendulum
- Box2D - LunarLander, BipedalWalker, CarRacing
- MuJoCo - Ant, HalfCheetah, Hopper, Humanoid, Walker2D
Procedural generation
- Procgen - 16 procedurally generated games
- Crafter - Survival crafting environment
- Craftax - JAX-accelerated crafting environment
- MiniGrid - Partially observable gridworld environments
- Griddly - Grid-based game engine environments
Roguelike games
- NetHack - The classic roguelike dungeon crawler
- MiniHack - Simplified NetHack tasks
- Pokémon Red - Gameboy game environment
- Link’s Awaken - Zelda game environment
DeepMind environments
- DM-Control - MuJoCo-based continuous control suite
- DM-Lab - 3D navigation and puzzle-solving
- BSuite - Behavior suite for RL agents
Multi-agent environments
- Butterfly - Cooperative PettingZoo environments
- MAgent - Large-scale multi-agent battle simulations
- SMAC - StarCraft Multi-Agent Challenge
- Neural MMO - Massively multi-agent survival game
- OpenSpiel - Game theory and multi-agent games
- Slime Volleyball - Competitive two-player game
- MicroRTS - Real-time strategy game
- CoGames - Cooperative game environments
Retro and simulation
- Stable-Retro - Classic console games via emulation
- VizDoom - 3D FPS environments
- MineRL - Minecraft learning environment
- Kinetix - Character animation and control
- GPUDrive - GPU-accelerated driving simulator
- ManiSkill - Robotic manipulation tasks
Custom environments
- NMMO - Neural MMO with custom wrappers
- Trade Sim - Economic trading simulation
- Tribal Village - Multi-agent village simulation
- Metta - Custom environment framework
- GVGAI - General Video Game AI framework
- Test - Mock environments for testing
Preprocessing wrappers
PufferLib provides several built-in preprocessing wrappers:ResizeObservation
Efficiently downscales observations using NumPy slicing:EpisodeStats
Tracks episode returns and lengths:ClipAction
Clips continuous actions to valid ranges:MultiagentEpisodeStats
Tracks per-agent statistics in multi-agent environments:MeanOverAgents
Averages info dictionaries across agents:Space emulation
PufferLib automatically handles complex observation and action spaces by “emulating” them as flat arrays:- Dict spaces - Flattened into single array
- Tuple spaces - Concatenated into single array
- Discrete/MultiDiscrete - Converted to integer arrays
GymnasiumPufferEnv and PettingZooPufferEnv. See Gymnasium integration and PettingZoo integration for details.
Creating environment instances
Each environment module provides amake() function and env_creator() function:
The
env_creator() returns a functools.partial that can be called multiple times to create identical environments for vectorization.Buffer management
PufferLib environments use pre-allocated NumPy buffers for zero-copy performance:Next steps
Gymnasium integration
Wrap single-agent Gymnasium environments
PettingZoo integration
Wrap multi-agent PettingZoo environments
Custom wrappers
Create your own environment wrappers
Ocean environments
Browse all Ocean environments