Expand description
A Rust implementation of OpenAI’s Gymnasium environments.
§Architecture
Unlike Python Gymnasium, gymnasia separates simulation from rendering.
The crate is organized into layers:
-
core::Env— pure simulation.step()andreset()perform physics only. No feature flags, no rendering code, no graphics imports. -
core::Renderable— a trait that produces arender::draw::DrawList(a backend-agnostic list of draw commands) from the current state. Always compiled —DrawListhas zero graphics dependencies. -
RenderEnv(requiresrenderfeature) — a wrapper that composes anEnv + Renderablewith a macroquad-backed screen. ImplementsEnvso it participates in wrapper chains. -
wrappers— composable behavior wrappers (TimeLimit,RecordEpisodeStatistics,NormalizeObservation, etc.) that implementEnvvia generic delegation.
This means the simulation compiles and runs with zero dependencies on any
graphics library. Rendering is opt-in via --features render.
§Quick start
use gymnasia::core::Env;
use gymnasia::envs::classical_control::cartpole::CartPoleEnv;
let mut env = CartPoleEnv::new();
env.reset(None, Default::default());
let result = env.step(1);Modules§
- core
- Core traits and types:
Env,StepResult,Flatten,Renderable. - envs
- Concrete environment implementations.
- render
- Drawing, rendering backend, and the
RenderEnvwrapper. - spaces
- Space descriptors:
Discrete,BoxSpace, etc. - utils
- Shared utilities: seeding, clip, etc.
- wrappers
- Composable environment wrappers. Composable environment wrappers.
Macros§
- delegate_
env - Implements
Envfor a wrapper by delegating all methods toself.env.