environment

package
v0.0.0-...-5c0e551 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExampleActionMax       = 10
	ExampleStateMax        = ExampleActionMax * 10
	ExampleNumberOfActions = 2*ExampleActionMax + 1
)

Variables

This section is empty.

Functions

func Add

func Add(name string, creator NewEnvironmentCreator) error

Add is used to register a new environment type. This is most likely called by an init function in the Environment's go file. The function returns an error if an environment with that name already exists.

func Create

func Create(name string, debug logger.Debug) (rlglue.Environment, error)

func NewCartpole

func NewCartpole(logger logger.Debug) (rlglue.Environment, error)

func NewExample

func NewExample(logger logger.Debug) (rlglue.Environment, error)

func NewReplay

func NewReplay(debug logger.Debug) (rlglue.Environment, error)

Types

type Cartpole

type Cartpole struct {
	logger.Debug
	// contains filtered or unexported fields
}

func (*Cartpole) GetAttributes

func (env *Cartpole) GetAttributes() rlglue.Attributes

GetAttributes returns attributes for this environment.

func (*Cartpole) Initialize

func (env *Cartpole) Initialize(run uint, attr rlglue.Attributes) error

Initialize configures the environment with the provided parameters and resets any internal state.

func (*Cartpole) Start

func (env *Cartpole) Start() rlglue.State

Start returns an initial observation.

func (*Cartpole) Step

func (env *Cartpole) Step(act rlglue.Action) (rlglue.State, float64, bool)

Step takes an action and provides the resulting reward, the new observation, and whether the state is terminal. For this continuous environment, it's only terminal if the action was invalid.

type Example

type Example struct {
	logger.Debug
	// contains filtered or unexported fields
}

Example is just a dumb test environment. state is adjusted by the action. Valid values are integers [0, ExampleNumberOfActions). Reward is equal to the new state. When |state| is >= ExampleStateMax, it's reset to 0.

func (*Example) GetAttributes

func (env *Example) GetAttributes() rlglue.Attributes

GetAttributes returns attributes for this environment.

func (*Example) Initialize

func (env *Example) Initialize(run uint, attr rlglue.Attributes) error

Initialize configures the environment with the provided parameters and resets any internal state.

func (*Example) Start

func (env *Example) Start() rlglue.State

Start returns an initial observation.

func (*Example) Step

func (env *Example) Step(act rlglue.Action) (rlglue.State, float64, bool)

Step takes an action and provides the resulting reward, the new observation, and whether the state is terminal. For this continuous environment, it's only terminal if the action was invalid.

type NewEnvironmentCreator

type NewEnvironmentCreator func(logger.Debug) (rlglue.Environment, error)

NewEnvironmentCreator is a function that can create an environment.

type Replay

type Replay struct {
	logger.Debug
	logger.ReplayData
	// contains filtered or unexported fields
}

Replay loads a previous data file and replays it. The previously chosen action is appended to the end of the state vector. When 'log-action-diff' is true, the environment logs errors if the same action was not chosen. The attribute "state-contains-replay" is always set to true.

func (*Replay) GetAttributes

func (env *Replay) GetAttributes() rlglue.Attributes

GetAttributes returns attributes for this environment.

func (*Replay) Initialize

func (env *Replay) Initialize(run uint, attr rlglue.Attributes) error

Initialize configures the environment with the provided parameters and resets any internal state.

func (*Replay) Start

func (env *Replay) Start() rlglue.State

Start returns an initial observation.

func (*Replay) Step

func (env *Replay) Step(act rlglue.Action) (rlglue.State, float64, bool)

Step takes an action and provides the resulting reward, the new observation, and whether the state is terminal. For this continuous environment, it's only terminal if the action was invalid.

Jump to

Keyboard shortcuts

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