narla.environments

ActionSpace

class narla.environments.ActionSpace(number_of_actions)[source]

Bases: object

ActionSpace for the Environment

Parameters

number_of_actions (int) – Number of available actions in the environment

property number_of_actions: int

Get the number of actions

Return type

int

sample()[source]

Sample an action from the Space

Return type

Tensor

property shape: Tuple[int, ...]

Shape of the ActionSpace

Return type

Tuple[int, …]

AvailableEnvironments

enum narla.environments.AvailableEnvironments(value)[source]

An enumeration.

Environment

class narla.environments.Environment(name, render=False)[source]

Bases: object

Environment base class

Parameters
  • name (AvailableEnvironments) – Name of the environment

  • render (bool) – If True will visualize the environment

property action_space: narla.environments.action_space.ActionSpace

Get the Environment’s ActionSpace

Return type

ActionSpace

property episode_reward: float

Get the total reward from the current episode

Return type

float

abstract has_been_solved(episode_rewards)[source]

Checks if the Environment has been solved based on historical rewards

Parameters

episode_rewards (List[float]) – List of past of rewards

Return type

bool

property observation_size: int

Access the size of the observation that the Environment produces

Return type

int

reset()[source]

Reset the environment

Return type

Tensor

Returns

Observation

step(action)[source]

Take a single action and advance the Environment one time step

Parameters

action (Tensor) – Action to be taken

Return type

Tuple[Tensor, Tensor, bool]

Returns

Observation, reward, terminated

GymEnvironment

class narla.environments.GymEnvironment(name, render=False)[source]

Bases: narla.environments.environment.Environment

Wrapper on Gymnasium Environments

Parameters
  • name (AvailableEnvironments) – Name of the environment

  • render (bool) – If True will visualize the environment

has_been_solved(episode_rewards)[source]

Checks if the Environment has been solved based on historical rewards

Parameters

episode_rewards (list) – List of past of rewards

Return type

bool

property observation_size: int

Access the size of the observation that the Environment produces

Return type

int

reset()[source]

Reset the environment

Return type

Tensor

Returns

Observation

step(action)[source]

Take a single action and advance the Environment one time step

Parameters

action (Tensor) – Action to be taken

Return type

Tuple[Tensor, Tensor, bool]

Returns

Observation, reward, terminated

GymEnvironments

enum narla.environments.GymEnvironments(value)[source]

An enumeration.

Valid values are as follows:

CART_POLE = <GymEnvironments.CART_POLE: 'CartPole-v1'>
MOUNTAIN_CAR = <GymEnvironments.MOUNTAIN_CAR: 'MountainCar-v0'>