/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. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. *
  13. * $Revision$
  14. * $Date$
  15. * $Author$
  16. * $HeadURL$
  17. *
  18. */
  19. package rlglue
  20. import (
  21. "fmt"
  22. )
  23. type absType struct {
  24. ints []int32
  25. doubles []float64
  26. chars []byte
  27. }
  28. func (at *absType) String() string {
  29. return fmt.Sprintf("{%v %v %v}", at.Ints(), at.Doubles(), at.Chars())
  30. }
  31. func (at *absType) Ints() []int32 {
  32. return at.ints
  33. }
  34. func (at *absType) Doubles() []float64 {
  35. return at.doubles
  36. }
  37. func (at *absType) Chars() []byte {
  38. return at.chars
  39. }
  40. type AbstractType interface {
  41. Ints() []int32
  42. Doubles() []float64
  43. Chars() []byte
  44. }
  45. func newAT(ints []int32, doubles []float64, chars []byte) AbstractType {
  46. return &absType{ints, doubles, chars}
  47. }
  48. type Observation AbstractType
  49. func NewObservation(ints []int32, doubles []float64, chars []byte) Observation {
  50. return newAT(ints, doubles, chars)
  51. }
  52. type Action AbstractType
  53. func NewAction(ints []int32, doubles []float64, chars []byte) Action {
  54. return newAT(ints, doubles, chars)
  55. }