Gymnasium environments
pip install fx2d, then gym.make or gym.make_vec. Vector environments step every copy's scene in one parallel call with the GIL released, and each copy matches a copy run on its own.
pip install fx2d for Gymnasium environments, scenes stepped in parallel across cores, and results that are the same bits on every platform. Underneath is an open-source C++20 rigid-body engine with SAT contacts, an XPBD solver and motorized joints, under BSD-3-Clause.

The playground runs the engine compiled to WebAssembly. You can drag bodies, spawn shapes, and change simulation settings. Its source is the same examples/playground program used by the desktop build.
From Python, train on an environment or step a scene of your own. From C++, define a scene in YAML, load it, then step it; use Fx2D/Core.h to add the raylib viewer, or work directly with FxScene for a headless simulation.
import gymnasium as gym
import fx2d.envs # registers the environments
envs = gym.make_vec("fx2d/Push-v0", num_envs=64)
obs, info = envs.reset(seed=0)
obs, reward, terminated, truncated, info = envs.step(envs.action_space.sample())#include "Fx2D/Core.h"
int main() {
auto scene = FxYAML::buildScene("Scene.yml");
FxRylbRenderer renderer(scene, 60);
renderer.run();
}#include "Fx2D/Scene.h"
#include "Fx2D/YamlUtils.h"
int main() {
auto scene = FxYAML::buildScene("Scene.yml");
auto ball = scene.get_entity("ball");
for (int i = 0; i < 600; ++i) {
scene.step(1.0 / 60.0);
std::cout << ball->pose << '\n';
}
}See the Python guide for the package and its environments, the installation guide for the C++ build, and your first scene for a YAML example.
The repository includes C++ programs and YAML scenes for the examples below.
Each simulation step finds potentially colliding pairs, generates contacts, and resolves contact and joint constraints. The collision detection and XPBD solver pages describe the algorithms and equations used in the implementation.
| Fx2D | |
|---|---|
| Python | pip install fx2d: NumPy state, step_many, Gymnasium and vector environments |
| Language | C++20; physics core built as a static library |
| Collision | Dynamic AABB tree + skin-aware SAT, opt-in speculative CCD |
| Solver | Substepped XPBD, warm-started, Coulomb friction, restitution |
| Joints | Revolute and prismatic with position / velocity / effort motors |
| Scenes | YAML with textures, joints, groups, reset |
| Headless | Yes, from Python or C++: no raylib, no window, same API |
| Rendering | raylib + Dear ImGui inspector, optional |
| License | BSD-3-Clause |
Fx2D is developed in the open. The roadmap lists planned work and known limitations, and the engineering notes record the measurements behind previous changes. The contributing guide covers code style, tests, and benchmarks.
Bug reports, reproducible scenes, documentation corrections, and code contributions are welcome on GitHub.