rl_games
cosmic_warp.rl.adapters.rl_games
rl_games adapter for :class:cosmic_warp.rl.VecEnv.
Wraps the neutral environment as an rl_games IVecEnv and wires it into
rl_games' environment registry so it can be trained with rl_games' PPO
(a2c_continuous). Observations are returned in rl_games' {"obs": tensor}
form, terminated/truncated are collapsed into a single dones with
truncated surfaced as infos["time_outs"] (enable value_bootstrap in
the config to use it).
register_env registers a built environment under a name; default_ppo_params
returns a minimal working training config. Requires the rl-games optional
dependency (pip install "cosmic-warp[rl-games]"), which pulls in PyTorch.
Tested against rl-games 1.6.
RlGamesVecEnv
RlGamesVecEnv(env: VecEnv)
Bases: IVecEnv
Present a :class:cosmic_warp.rl.VecEnv through the rl_games IVecEnv API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
VecEnv
|
The COSMIC WARP environment to wrap. |
required |
Source code in cosmic_warp/rl/adapters/rl_games.py
vec_env
property
vec_env: VecEnv
The wrapped COSMIC WARP :class:~cosmic_warp.rl.VecEnv (for
evaluation loops outside the trainer).
register_env
register_env(name: str, env: RlGamesVecEnv) -> None
Register a built environment with rl_games under name.
After this, an rl_games config with config.env_name == name resolves to
env, for training and for the player (Runner.create_player(),
which builds its env through env_creator by default). Registration is
idempotent per name (re-registering overwrites).
Source code in cosmic_warp/rl/adapters/rl_games.py
default_ppo_params
default_ppo_params(
env_name: str,
num_envs: int,
horizon_length: int = 24,
num_minibatches: int = 4,
units=(128, 128),
learning_rate: float = 0.001,
max_epochs: int = 100,
device: str = "cuda:0",
train_dir: str | None = None,
) -> dict
A minimal, working rl_games PPO config for continuous control.
Returns the {"params": {...}} dict expected by Runner.load. A
convenience default, not a tuned recipe. device is used for training
and for the player (Runner.create_player()). train_dir redirects
rl_games' log/checkpoint output (default: rl_games' runs/ in the
working dir).