PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/rlglue/example/environment.go

https://code.google.com/p/go-glue/
Go | 29 lines | 26 code | 3 blank | 0 comment | 1 complexity | c56a5b7433875f1f4bda4b4ce24015c5 MD5 | raw file
 1package example
 2
 3import (
 4	"code.google.com/p/go-glue/rlglue"
 5	"fmt"
 6	"math/rand"
 7)
 8
 9type Environment int
10
11func (re Environment) EnvInit() (taskString string) {
12	format := "VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (0 %d) ACTIONS INTS (0 1) REWARDS (0 1.0)"
13	tstr := fmt.Sprintf(format, re-1)
14	return tstr
15}
16func (re Environment) EnvStart() (obs rlglue.Observation) {
17	return rlglue.NewObservation([]int32{rand.Int31n(int32(re))}, []float64{}, []byte{})
18}
19func (re Environment) EnvStep(action rlglue.Action) (obs rlglue.Observation, r float64, t bool) {
20	obs = rlglue.NewObservation([]int32{rand.Int31n(int32(re))}, []float64{}, []byte{})
21	r = -1
22	t = rand.Intn(2) == 1
23	return
24}
25func (re Environment) EnvCleanup() {
26}
27func (re Environment) EnvMessage(message string) (reply string) {
28	return ""
29}