Functional Environment#


class gymnasium.experimental.FuncEnv(options: dict[str, Any] | None = None)#

Base class (template) for functional envs.

This API is meant to be used in a stateless manner, with the environment state being passed around explicitly. That being said, nothing here prevents users from using the environment statefully, it’s just not recommended. A functional env consists of the following functions (in this case, instance methods): - initial: returns the initial state of the POMDP - observation: returns the observation in a given state - transition: returns the next state after taking an action in a given state - reward: returns the reward for a given (state, action, next_state) tuple - terminal: returns whether a given state is terminal - state_info: optional, returns a dict of info about a given state - step_info: optional, returns a dict of info about a given (state, action, next_state) tuple

The class-based structure serves the purpose of allowing environment constants to be defined in the class, and then using them by name in the code itself.

For the moment, this is predominantly for internal use. This API is likely to change, but in the future we intend to flesh it out and officially expose it to end users.

Initialize the environment constants.

gymnasium.experimental.FuncEnv.initial(self, rng: Any) StateType#

Initial state.

gymnasium.experimental.FuncEnv.transition(self, state: StateType, action: ActType, rng: Any) StateType#


gymnasium.experimental.FuncEnv.observation(self, state: StateType) ObsType#


gymnasium.experimental.FuncEnv.reward(self, state: StateType, action: ActType, next_state: StateType) RewardType#


gymnasium.experimental.FuncEnv.terminal(self, state: StateType) TerminalType#

Terminal state.

gymnasium.experimental.FuncEnv.state_info(self, state: StateType) dict#

Info dict about a single state.

gymnasium.experimental.FuncEnv.step_info(self, state: StateType, action: ActType, next_state: StateType) dict#

Info dict about a full transition.

gymnasium.experimental.FuncEnv.transform(self, func: Callable[[Callable], Callable])#

Functional transformations.

gymnasium.experimental.FuncEnv.render_image(self, state: StateType, render_state: RenderStateType) tuple[RenderStateType, numpy.ndarray]#

Show the state.

gymnasium.experimental.FuncEnv.render_init(self, **kwargs) RenderStateType#

Initialize the render state.

gymnasium.experimental.FuncEnv.render_close(self, render_state: RenderStateType)#

Close the render state.