Environment interface

class tensorforce.environments.Environment[source]

Tensorforce environment interface.

actions()[source]

Returns the action space specification.

Returns:Arbitrarily nested dictionary of action descriptions with the following attributes:
  • type ("bool" | "int" | "float") – action data type (required).
  • shape (int > 0 | iter[int > 0]) – action shape (default: scalar).
  • num_actions (int > 0) – number of discrete action values (required for type "int").
  • min_value/max_value (float) – minimum/maximum action value (optional for type "float").
Return type:specification
close()[source]

Closes the environment.

static create(environment, max_episode_timesteps=None, **kwargs)[source]

Creates an environment from a specification.

Parameters:
  • environment (specification | Environment object) – JSON file, specification key, configuration dictionary, library module, or Environment object (required).
  • max_episode_timesteps (int > 0) – Maximum number of timesteps per episode, overwrites the environment default if defined (default: environment default).
  • kwargs – Additional arguments.
execute(actions)[source]

Executes the given action(s) and advances the environment by one step.

Parameters:actions (dict[action]) – Dictionary containing action(s) to be executed (required).
Returns:Dictionary containing next state(s), whether a terminal state is reached or 2 if the episode was aborted, and observed reward.
Return type:((dict[state], bool | 0 | 1 | 2, float))
max_episode_timesteps()[source]

Returns the maximum number of timesteps per episode.

Returns:Maximum number of timesteps per episode.
Return type:int
reset()[source]

Resets the environment to start a new episode.

Returns:Dictionary containing initial state(s) and auxiliary information.
Return type:dict[state]
states()[source]

Returns the state space specification.

Returns:Arbitrarily nested dictionary of state descriptions with the following attributes:
  • type ("bool" | "int" | "float") – state data type (default: "float").
  • shape (int | iter[int]) – state shape (required).
  • num_states (int > 0) – number of discrete state values (required for type "int").
  • min_value/max_value (float) – minimum/maximum state value (optional for type "float").
Return type:specification