Documentation ¶
Index ¶
- type Client
- func (c *Client) ActionSpace(id InstanceID) (*Space, error)
- func (c *Client) Close(id InstanceID) error
- func (c *Client) CloseMonitor(id InstanceID) error
- func (c *Client) ContainsAction(id InstanceID, act interface{}) (bool, error)
- func (c *Client) Create(envID string) (InstanceID, error)
- func (c *Client) ListAll() (map[InstanceID]string, error)
- func (c *Client) ObservationSpace(id InstanceID) (*Space, error)
- func (c *Client) Reset(id InstanceID) (observation interface{}, err error)
- func (c *Client) SampleAction(id InstanceID) (interface{}, error)
- func (c *Client) Shutdown() error
- func (c *Client) StartMonitor(id InstanceID, dir string, force, resume, videoCallable bool) error
- func (c *Client) Step(id InstanceID, action interface{}, render bool) (observation interface{}, reward float64, done bool, info interface{}, ...)
- func (c *Client) Upload(dir, apiKey, algorithmID string) error
- type InstanceID
- type Space
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 ¶
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) 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.
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.