gym

package
v0.0.0-...-15b68c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client interfaces with a Gym HTTP server.

func NewClient

func NewClient(baseURL string) (*Client, error)

NewClient creates a client with the given base URL.

For example, the base URL might be

http://localhost:8080

This fails if the baseURL is invalid.

func (*Client) ActionSpace

func (c *Client) ActionSpace(id InstanceID) (*Space, error)

ActionSpace fetches the action space.

func (*Client) Close

func (c *Client) Close(id InstanceID) error

Close closes the environment instance.

func (*Client) CloseMonitor

func (c *Client) CloseMonitor(id InstanceID) error

CloseMonitor stops monitoring the environment.

func (*Client) ContainsAction

func (c *Client) ContainsAction(id InstanceID, act interface{}) (bool, error)

ContainsAction checks if an action is contained in the action space.

Currently, only int action types are supported.

func (*Client) Create

func (c *Client) Create(envID string) (InstanceID, error)

Create creates a new instance of an environment.

func (*Client) ListAll

func (c *Client) ListAll() (map[InstanceID]string, error)

ListAll lists all instantiated environments. The result maps between instance IDs and environment IDs.

func (*Client) ObservationSpace

func (c *Client) ObservationSpace(id InstanceID) (*Space, error)

ObservationSpace fetches the observation space.

func (*Client) Reset

func (c *Client) Reset(id InstanceID) (observation interface{}, err error)

Reset resets the environment instance.

The resulting observation type may vary. For discrete spaces, it is an int. For vector spaces, it is a []float64.

func (*Client) SampleAction

func (c *Client) SampleAction(id InstanceID) (interface{}, error)

SampleAction samples an action uniformly.

The action is turned into a Go type just like Reset() turns observations into Go types.

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown stops the server.

func (*Client) StartMonitor

func (c *Client) StartMonitor(id InstanceID, dir string, force, resume, videoCallable bool) error

StartMonitor starts monitoring the environment.

func (*Client) Step

func (c *Client) Step(id InstanceID, action interface{}, render bool) (observation interface{},
	reward float64, done bool, info interface{}, err error)

Step takes a step in the environment.

The action type may vary. For discrete spaces, it should be an int. For vector spaces, it should be a []float64 or a []float32.

See Reset() for information on the observation type.

func (*Client) Upload

func (c *Client) Upload(dir, apiKey, algorithmID string) error

Upload uploads the monitor results from the directory to the Gym website.

If apiKey is "", then the "OPENAI_GYM_API_KEY" environment variable is used.

type InstanceID

type InstanceID string

InstanceID uniquely identifies a running instance.

type Space

type Space struct {
	// Name is the name of the space, such as "Box", "HighLow",
	// or "Discrete".
	Name string `json:"name"`

	// Properties for Box spaces.
	Shape []int     `json:"shape"`
	Low   []float64 `json:"low"`
	High  []float64 `json:"high"`

	// Properties for Discrete spaces.
	N int `json:"n"`

	// Properties for HighLow spaces.
	NumRows int       `json:"num_rows"`
	Matrix  []float64 `json:"matrix"`
}

Space stores information about an action space or an observation space.

Directories

Path Synopsis
demo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL