Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EnvSpecs = []*EnvSpec{}/* 202 elements not displayed */
Functions ¶
Types ¶
type Env ¶
type Env interface {
// Spec returns details about the environment.
Spec() *EnvSpec
// Reset resets the environment to a start state.
Reset() error
// Step sends the given events and advances the
// episode by the given amount of time.
//
// If done is true, then the episode has ended.
// After an episode ends, Reset must be called once
// before Step may be called again.
// However, observations may be made even after the
// episode has ended.
//
// Typical event types are *chrome.MouseEvent and
// *chrome.KeyEvent.
Step(t time.Duration, events ...interface{}) (reward float64,
done bool, err error)
// Observe produces an observation for the current
// state of the environment.
Observe() (Obs, error)
// Close cleans up resources used by the environment.
//
// After Close is called, the Env should not be used
// anymore by any Goroutine.
Close() error
// Log returns internal log messages.
// For example, it might return information about 404
// errors.
//
// The returned list is a copy and may be modified by
// the caller.
Log() []string
}
An Env controls and observes an environment.
It is not safe to run an methods on an Env from more than one Goroutine at a time.
The lifecycle of an environment is as follows: First, Reset is called to start an episode. Then, Step and Observe may be called repeatedly in any order until Step returns done=true to signal that the episode has ended. Once the episode has ended, Observe may be called but Step may not be. Call Reset to start a new episode and begin the process over again.
When you are done with an Env, you must close it to clean up resources associated with it.
func CursorEnv ¶
CursorEnv creates a wrapped environment which renders a cursor at the current mouse location.
At every episode, the mouse is initialized to the given x and y coordinates.
By default, Chrome will not render a mouse. Thus, it is necessary to render a mouse manually.
When the resulting Env is closed, e is closed as well.
func NewEnv ¶
NewEnv creates a new environment inside the default Docker image with the default settings.
This may take a few minutes to run the first time, since it has to download a large Docker image. If the download takes too long, NewEnv may time out. If this happens, it is recommended that you download the image manually.
func NewEnvOptions ¶
NewEnvOptions creates a new environment with the given set of options.
func RecordEnv ¶
RecordEnv creates an Env wrapper which stores a new Recording for every episode.
Recordings are stored inside the given directory. Each recording is assigned a pseudo-random directory name to prevent collisions. However, the names all begin with "recording_".
Closing the resulting Env will automatically close e.
type EnvSpec ¶
type EnvSpec struct {
Name string `bson:"Name"`
BaseURL string `bson:"BaseURL"`
Width int `bson:"Width"`
Height int `bson:"Height"`
AllCanvas bool `bson:"AllCanvas"`
Options string `bson:"Options"`
KeyWhitelist []string `bson:"KeyWhitelist,omitempty"`
MouseType string `bson:"MouseType"`
MouseRequired bool `bson:"MouseRequired"`
VariantOf string `bson:"VariantOf"`
}
An EnvSpec contains meta-data about an environment.
func SpecForName ¶
SpecForName finds the first entry in EnvSpecs with the given name. If no entry is found, nil is returned.
type Options ¶
type Options struct {
// CustomImage, if non-empty, specifies a custom
// Docker image to use for the environment.
CustomImage string
// GamesDir, if non-empty, specifies a directory on
// the host to mount into the Docker container as a
// downloaded_games folder.
GamesDir string
// DevtoolsHost, if non-empty, specifies the host of
// an already-running Chrome's DevTools server.
//
// If this is non-empty, a Docker container will not
// be launched, and the CustomImage and GamesDir
// options should not be used.
// Further, the GameHost field must be set.
DevtoolsHost string
// GameHost, if non-empty, specifies the host for the
// downloaded_games file server.
// This can only be used in conjunction with
// DevtoolsHost.
GameHost string
// Compression, if set, allows observations to be
// compressed in a lossy fashion.
// Using compression may provide a performance boost, but
// at the expense of observation integrity.
Compression bool
// CompressionQuality controls the quality of compressed
// observations if Compression is set.
// The value ranges from 0 to 100 (inclusive).
CompressionQuality int
}
Options specifies how to configure a new Env.
By default, environments run inside of Docker. In this case, the Docker image can be manually specified with CustomImage, and/or a custom games directory can be specified with GamesDir.
Sometimes, it might be desirable to run an Env directly inside an arbitrary instance of Chrome without starting a Docker container. In this case, you can set the DevtoolsHost field. You will also need to manually start a file-system server for your downloaded_games directory and point GameHost to this server.
type Recording ¶
type Recording struct {
// contains filtered or unexported fields
}
Recording is an on-disk record of observations and actions in an environment rollout.
It is not safe to run methods on a Recording from more than one Goroutine at a time. Further, it is not safe to open a Recording if another Goroutine or program is writing to it.
func CreateRecording ¶
CreateRecording creates a new Recording at the given path.
func OpenRecording ¶
OpenRecording opens an existing Recording from a directory at the given path.
func (*Recording) ReadObs ¶
ReadObs reads the observation at the given index. It fails if the index is out of range.
func (*Recording) ReadStep ¶
ReadStep reads the step at the given index. It fails if the index is out of range.
Directories
¶
| Path | Synopsis |
|---|---|
|
bindings
|
|
|
muniverse-bind
command
Command muniverse-bind uses stdin and stdout to serve an API for controlling muniverse environments.
|
Command muniverse-bind uses stdin and stdout to serve an API for controlling muniverse environments. |
|
Package chrome implements the Chrome DevTools protocol.
|
Package chrome implements the Chrome DevTools protocol. |
|
Command codegen generates a file called spec.go with specifications for each available environment.
|
Command codegen generates a file called spec.go with specifications for each available environment. |
|
container
|
|
|
netwait
command
Command netwait waits for an incoming TCP connection, then exits when the TCP connection ends.
|
Command netwait waits for an incoming TCP connection, then exits when the TCP connection ends. |