ml.tasks.environments.base

Defines a generic reinforcement learning environment class.

class ml.tasks.environments.base.Environment[source]

Bases: ABC, Generic[RLState, RLAction]

abstract reset(seed: int | None = None) RLState[source]

Gets the initial environment state.

Parameters:

seed – The initial random seed to use

Returns:

The initial state of the environment.

abstract render(state: RLState) ndarray | Tensor[source]

Renders the environment.

Parameters:

state – The state to render

Returns:

The rendered environment as a single frame, as an image array.

abstract sample_action() RLAction[source]

Samples an action from the environment’s action space.

Returns:

The sampled action.

abstract step(action: RLAction) RLState[source]

Performs a single step in the environment.

Parameters:

action – The action to perform in the environment.

Returns:

The next state of the environment.

abstract terminated(state: RLState) bool[source]

Checks if the environment has finished.

Parameters:

state – The most recent state

Returns:

If the environment has finished

property fps: int