all.environments

class all.environments.AtariEnvironment(name, *args, **kwargs)

Bases: all.environments.gym.GymEnvironment

duplicate(n)

Create n copies of this environment.

property name

The name of the environment.

class all.environments.Environment

Bases: abc.ABC

A reinforcement learning Environment.

In reinforcement learning, an Agent learns by interacting with an Environment. An Environment defines the dynamics of a particular problem: the states, the actions, the transitions between states, and the rewards given to the agent. Environments are often used to benchmark reinforcement learning agents, or to define real problems that the user hopes to solve using reinforcement learning.

abstract property action_space

The Space representing the range of possible actions.

Returns

An object of type Space that represents possible actions the agent may take

Return type

Space

abstract close()

Clean up any extraneaous environment objects.

abstract property device

The torch device the environment lives on.

abstract duplicate(n)

Create n copies of this environment.

abstract property name

The name of the environment.

property observation_space

Alias for Environemnt.state_space.

Returns

An object of type Space that represents possible states the agent may observe

Return type

Space

abstract render(**kwargs)

Render the current environment state.

abstract reset()

Reset the environment and return a new intial state.

Returns

The initial state for the next episode.

Return type

State

abstract property state

The State of the Environment at the current timestep.

abstract property state_space

The Space representing the range of observable states.

Returns

An object of type Space that represents possible states the agent may observe

Return type

Space

abstract step(action)

Apply an action and get the next state.

Parameters

action (Action) – The action to apply at the current time step.

Returns

  • all.environments.State – The State of the environment after the action is applied. This State object includes both the done flag and any additional “info”

  • float – The reward achieved by the previous action

class all.environments.GymEnvironment(env, device=torch.device)

Bases: all.environments.abstract.Environment

A wrapper for OpenAI Gym environments (see: https://gym.openai.com).

This wrapper converts the output of the gym environment to PyTorch tensors, and wraps them in a State object that can be passed to an Agent. This constructor supports either a string, which will be passed to the gym.make(name) function, or a preconstructed gym environment. Note that in the latter case, the name property is set to be the whatever the name of the outermost wrapper on the environment is.

Parameters
  • env – Either a string or an OpenAI gym environment

  • device (optional) – the device on which tensors will be stored

property action_space

The Space representing the range of possible actions.

Returns

An object of type Space that represents possible actions the agent may take

Return type

Space

close()

Clean up any extraneaous environment objects.

property device

The torch device the environment lives on.

duplicate(n)

Create n copies of this environment.

property env
property name

The name of the environment.

render(**kwargs)

Render the current environment state.

reset()

Reset the environment and return a new intial state.

Returns

The initial state for the next episode.

Return type

State

seed(seed)
property state

The State of the Environment at the current timestep.

property state_space

The Space representing the range of observable states.

Returns

An object of type Space that represents possible states the agent may observe

Return type

Space

step(action)

Apply an action and get the next state.

Parameters

action (Action) – The action to apply at the current time step.

Returns

  • all.environments.State – The State of the environment after the action is applied. This State object includes both the done flag and any additional “info”

  • float – The reward achieved by the previous action