Gymnax
lerax.compatibility.gymnax.GymnaxToLeraxEnv
Bases:
Wrapper of a Gymnax environment to make it compatible with Lerax.
Note
For the sake of simplicity, truncation is not handled and always set to False. To keep the API consistent, info returned by step is always an empty dict.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
Action space of the environment. |
|
|
Observation space of the environment. |
|
|
Gymnax environment being wrapped. |
|
|
Parameters for the Gymnax environment. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
|
Gymnax environment to wrap. |
required |
params
|
|
Parameters for the Gymnax environment. |
required |
action_space
instance-attribute
observation_space
instance-attribute
reward
reward(
state: GymnaxEnvState,
action: Array,
next_state: GymnaxEnvState,
*,
key: Key,
) -> Float[Array, ""]
transition_info
render_states
render_states(
states: Sequence[StateType],
renderer: AbstractRenderer | Literal["auto"] = "auto",
dt: float = 0.0,
)
Render a sequence of frames from multiple states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
|
A sequence of environment states to render. |
required |
renderer
|
|
The renderer to use for rendering. If "auto", uses the default renderer. |
'auto'
|
dt
|
|
The time delay between rendering each frame, in seconds. |
0.0
|
render_stacked
render_stacked(
states: StateType,
renderer: AbstractRenderer | Literal["auto"] = "auto",
dt: float = 0.0,
)
Render multiple frames from stacked states.
Stacked states are typically batched states stored in a pytree structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
|
A pytree of stacked environment states to render. |
required |
renderer
|
|
The renderer to use for rendering. If "auto", uses the default renderer. |
'auto'
|
dt
|
|
The time delay between rendering each frame, in seconds. |
0.0
|
reset
Wrap the functional logic into a Gym API reset method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
|
A JAX PRNG key for any stochasticity in the reset. |
required |
Returns:
| Type | Description |
|---|---|
|
A tuple of the initial state, initial observation, and additional info. |
step
step(
state: StateType, action: ActType, *, key: Key
) -> tuple[
StateType,
ObsType,
Float[Array, ""],
Bool[Array, ""],
Bool[Array, ""],
dict,
]
Wrap the functional logic into a Gym API step method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
|
The current environment state. |
required |
action
|
|
The action to take. |
required |
key
|
|
A JAX PRNG key for any stochasticity in the step. |
required |
Returns:
| Type | Description |
|---|---|
|
A tuple of the next state, observation, reward, terminal flag, truncate flag, and additional info. |
lerax.compatibility.gymnax.LeraxToGymnaxEnv
Bases:
Wrapper of an Lerax environment to make it compatible with Gymnax.
Note
Since Gymnax does not have a truncation concept, truncation and termination are combined into a single "done" signal.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
Lerax environment being wrapped. |
|
|
Current state of the environment. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
|
Lerax environment to wrap. |
required |
lerax.compatibility.gymnax.gymnax_space_to_lerax_space
Returns a Lerax space corresponding to the given Gymnax space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
|
Gymnax space to convert. |
required |
Returns:
| Type | Description |
|---|---|
|
The corresponding Lerax space. |
lerax.compatibility.gymnax.lerax_to_gymnax_space
Returns a Gymnax space corresponding to the given Lerax space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
|
Lerax space to convert. |
required |
Returns:
| Type | Description |
|---|---|
|
The corresponding Gymnax space. |