PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/rlglue/tests/test_message_agent.go

https://code.google.com/p/go-glue/
Go | 43 lines | 40 code | 3 blank | 0 comment | 8 complexity | 56220a35ca76cbe78a570c947052c82e MD5 | raw file
 1package main
 2
 3import (
 4	"go-glue.googlecode.com/hg/rlglue"
 5)
 6
 7type MessageAgent struct {
 8	whichEpisode	int
 9	emptyAction	rlglue.Action
10}
11
12func (ea *MessageAgent) AgentInit(taskString string) {
13	ea.whichEpisode = 0
14	ea.emptyAction = rlglue.NewAction([]int32{}, []float64{}, []byte{})
15}
16func (ea *MessageAgent) AgentStart(obs rlglue.Observation) (act rlglue.Action) {
17	return ea.emptyAction
18}
19func (ea *MessageAgent) AgentStep(reward float64, obs rlglue.Observation) (act rlglue.Action) {
20	return ea.emptyAction
21}
22func (ea *MessageAgent) AgentEnd(reward float64) {
23}
24func (ea *MessageAgent) AgentCleanup() {
25}
26func (ea *MessageAgent) AgentMessage(message string) (reply string) {
27	reply = message
28	if message == "" {
29		reply = "empty"
30	}
31	if message == "empty" {
32		reply = ""
33	}
34	if message == "null" {
35		reply = ""
36	}
37	return
38}
39func main() {
40	if err := rlglue.LoadAgent(new(MessageAgent)); err != nil {
41		panic(err)
42	}
43}