Development¶
This page covers building Procgen2 from source and where to find the guides for implementing games.
Building the games¶
The games depend on SDL3 and the SDL3_image extension. On Linux, both are likely available from your package manager. The games are built with CMake.
To build every game, run the following from the repository root:
mkdir build
cd build
cmake ..
cmake --build .
Each game is compiled to a shared library under build/games/<game>/ (.so on Linux, .dylib on macOS, .dll on Windows).
Loading a game from Python¶
Compiled games are loaded from Python with CEnv, which exposes them as Gymnasium environments:
from cenv.cenv import CEnv
env = CEnv("build/games/caveflyer/libCaveFlyer.so", options={"width": 512, "height": 512})
obs, info = env.reset()
See interactive_viewer.py in the repository root for a complete example that plays a game with the keyboard.
CEnv¶
CEnv is the interface that lets environments be implemented in a compiled language and called from Python. Any language that can produce a shared library using the C calling convention will work. See the CEnv usage guide for the full interface.
Implementing a game¶
New games should roughly mimic the structure and style of the Coinrun implementation, which uses an Entity Component System (ECS). See the development guide for a walkthrough.