Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Env

The main Gym.js class. It encapsulates an environment with arbitrary behind-the-scenes dynamics. An environment can be partially or fully observed.

This class is derived from OpenAI's Gym and thus the API is very similar and in most cases the same. The key differences are as follows:

  • gym.js uses tensorflow.js for tensor manipulation instead of numpy. As a result, all of the returned datatypes are tf.Tensor in place of np.array.
  • The render method prints the environment to the console. renderHTML either returns an HTML string or, in the case of a Phaser env, renders on the canvas.

    The main API methods that users of this class need to know are:

    • step
    • reset
    • render
    • close
    • seed

    And set the following attributes:

    • action_space: The Space object corresponding to valid actions
    • observation_space: The Space object corresponding to valid observations
    • reward_range: A tuple corresponding to the min and max possible rewards

Hierarchy

  • Env

Implemented by

Index

Properties

action_space

action_space: Space

The possible actions that can be taken. Either continuous or discrete.

observation_space

observation_space: Space

The observable world.

reward_range

reward_range: Space

The possible rewards an agent can achieve.

Methods

close

  • close(): void
  • Terminate the game session and close environment

    Returns void

render

  • render(): void
  • Display the game environment

    Returns void

reset

  • reset(): tf.Tensor
  • Restore the environment to a random starting state

    Returns tf.Tensor

    The initial observation

seed

  • seed(seed: number): void
  • Seed the randomness in the environment

    Parameters

    • seed: number

      The seed value

    Returns void

step

  • step(action: number): [tf.Tensor, number, boolean, __type]
  • step(time: number, delta: number, action: number): [tf.Tensor, number, boolean, __type]
  • Steps the environment according to some action.

    Parameters

    • action: number

      The action to take (in action_space)

    Returns [tf.Tensor, number, boolean, __type]

    • [observation, reward, done, info] tuple
  • Overloaded step function for Phaser Games.

    Parameters

    • time: number

      Phaser time

    • delta: number

      Phaser time delta

    • action: number

      The action to take (in action_space)

    Returns [tf.Tensor, number, boolean, __type]

    • [observation, reward, done, info] tuple

Generated using TypeDoc