lit_sb3.wrappers.action_masker
source module lit_sb3.wrappers.action_masker
Classes
-
ActionMasker — Env wrapper providing the method required to support masking.
source class ActionMasker(env: gym.Env, action_mask_fn: str | Callable[[gym.Env], np.ndarray])
Bases : gym.Wrapper
Env wrapper providing the method required to support masking.
Exposes a method called action_masks(), which returns masks for the wrapped env. This wrapper is not needed if the env exposes the expected method itself.
Parameters
-
env : gym.Env — the Gym environment to wrap
-
action_mask_fn : str | Callable[[gym.Env], np.ndarray] — A function that takes a Gym environment and returns an action mask, or the name of such a method provided by the environment.
Attributes
-
metadata : dict[str, Any] — attr:
Env:attr:metadata. -
render_mode : str | None — attr:
Env:attr:render_mode. -
spec : EnvSpec | None — attr:
Env:attr:specattribute with theWrapperSpecif the wrapper inherits fromEzPickle. -
action_space : spaces.Space[ActType] | spaces.Space[WrapperActType] — attr:
Env:attr:action_spaceunless overwritten then the wrapper :attr:action_spaceis used. -
observation_space : spaces.Space[ObsType] | spaces.Space[WrapperObsType] — attr:
Env:attr:observation_spaceunless overwritten then the wrapper :attr:observation_spaceis used. -
unwrapped : Env[ObsType, ActType] — Returns the base environment of the wrapper.
-
np_random_seed : int | None — attr:
np_random_seed. -
np_random : np.random.Generator — attr:
Env:attr:np_randomattribute.
Methods
source method ActionMasker.action_masks() → np.ndarray