PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/rlglue/types.go

https://code.google.com/p/go-glue/
Go | 71 lines | 37 code | 13 blank | 21 comment | 0 complexity | 9687c3ed9fb8c19d92b66501e03b9c25 MD5 | raw file
 1/* 
 2* Copyright (C) 2010, John Asmuth
 3
 4 Licensed under the Apache License, Version 2.0 (the "License");
 5 you may not use this file except in compliance with the License.
 6 You may obtain a copy of the License at
 7
 8     http://www.apache.org/licenses/LICENSE-2.0
 9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15* 
16*  $Revision$
17*  $Date$
18*  $Author$
19*  $HeadURL$
20* 
21*/
22
23package rlglue
24
25import (
26	"fmt"
27)
28
29type absType struct {
30	ints    []int32
31	doubles []float64
32	chars   []byte
33}
34
35func (at *absType) String() string {
36	return fmt.Sprintf("{%v %v %v}", at.Ints(), at.Doubles(), at.Chars())
37}
38
39func (at *absType) Ints() []int32 {
40	return at.ints
41}
42
43func (at *absType) Doubles() []float64 {
44	return at.doubles
45}
46
47func (at *absType) Chars() []byte {
48	return at.chars
49}
50
51type AbstractType interface {
52	Ints() []int32
53	Doubles() []float64
54	Chars() []byte
55}
56
57func newAT(ints []int32, doubles []float64, chars []byte) AbstractType {
58	return &absType{ints, doubles, chars}
59}
60
61type Observation AbstractType
62
63func NewObservation(ints []int32, doubles []float64, chars []byte) Observation {
64	return newAT(ints, doubles, chars)
65}
66
67type Action AbstractType
68
69func NewAction(ints []int32, doubles []float64, chars []byte) Action {
70	return newAT(ints, doubles, chars)
71}