Compatibility¶
sekai.compat bridges sekai and gymnasium, and multi-agent sekai envs and PettingZoo. The
bridges need the optional dependencies: pip install "sekai[gymnasium]", or
pip install "sekai[pettingzoo]" (which includes gymnasium). See
Migrating from gymnasium and Multi-agent.
Functions¶
to_gymnasium
¶
Wrap a sekai Env as a gymnasium.Env (spaces converted, tuples returned).
from_gymnasium
¶
Wrap a gymnasium.Env as a sekai Env (StepResult/ResetResult returned).
space_to_gymnasium
¶
Convert a sekai space to the equivalent gymnasium space.
space_from_gymnasium
¶
Convert a gymnasium space to the equivalent sekai space.
to_pettingzoo
¶
Wrap a sekai MultiAgentEnv as a PettingZoo ParallelEnv.
from_pettingzoo
¶
Wrap a PettingZoo ParallelEnv as a sekai MultiAgentEnv.
Classes¶
These are importable from sekai.compat (loaded on first access).
SekaiToGymnasium
¶
Exposes a sekai Env through the gymnasium API.
Use it to train sekai environments with gymnasium-based libraries
(Stable-Baselines3, CleanRL, RLlib, ...). Pass a renderer to support
render(): render_mode defaults to "rgb_array"; pass render_mode="ansi"
explicitly for a renderer that returns text. "human" is not supported, as
sekai renderers return frames instead of opening a window; wrap the result
in gymnasium.wrappers.HumanRendering to display "rgb_array" frames.
GymnasiumToSekai
¶
Exposes a gymnasium Env through the sekai API.
The gymnasium env keeps its own RNG; seeds passed to reset() go straight to it, and self.rng is the gymnasium env's np_random. A NumPy integer seed is passed on as an int; a Generator becomes the gymnasium env's np_random (gymnasium's reset() itself only takes int seeds).
GymnasiumRenderer
¶
A sekai Renderer that calls a wrapped gymnasium env's own render().
SekaiToPettingZoo
¶
SekaiToPettingZoo(env: MultiAgentEnv[Any, Any, Any])
Bases: ParallelEnv
Exposes a sekai MultiAgentEnv through PettingZoo's Parallel API.
Spaces are converted to gymnasium spaces; results become the usual
(observations, rewards, terminations, truncations, infos) dicts.
Event-driven sekai envs (e.g. LimitOrderBookMarket) return observations
only for the agents that act next, which a strict Parallel-API consumer
may not expect; their rewards and flags still cover every agent.
PettingZooToSekai
¶
PettingZooToSekai(env: Any)
Bases: MultiAgentEnv[Any, Any, Any]
Exposes a PettingZoo ParallelEnv through the sekai MultiAgentEnv API.
The PettingZoo env keeps its own randomness; seeds passed to reset() go straight to it (a NumPy integer as an int). PettingZoo has no standard way to hand an env a Generator, so a Generator seed raises TypeError.