-
Notifications
You must be signed in to change notification settings - Fork 21
/
datatypes.go
64 lines (53 loc) · 1.6 KB
/
datatypes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package agogo
import (
"io"
dual "github.com/gorgonia/agogo/dualnet"
"github.com/gorgonia/agogo/game"
"github.com/gorgonia/agogo/mcts"
)
// Config for the AZ structure.
// It holds attributes that impacts the MCTS and the Neural Network
// as well as object that facilitates the interactions with the end-user (eg: OutputEncoder).
type Config struct {
Name string
NNConf dual.Config
MCTSConf mcts.Config
UpdateThreshold float64
MaxExamples int // maximum number of examples
// extensions
Encoder GameEncoder
OutputEncoder OutputEncoder
Augmenter Augmenter
}
// GameEncoder encodes a game state as a slice of floats
type GameEncoder func(a game.State) []float32
// OutputEncoder encodes the entire meta state as whatever.
//
// An example OutputEncoder is the GifEncoder. Another example would be a logger.
type OutputEncoder interface {
Encode(ms game.MetaState) error
Flush() error
}
// Augmenter takes an example, and creates more examples from it.
type Augmenter func(a Example) []Example
// Example is a representation of an example.
type Example struct {
Board []float32
Policy []float32
Value float32
}
// Dualer is an interface for anything that allows getting out a *Dual.
//
// Its sole purpose is to form a monoid-ish data structure for Agent.NN
type Dualer interface {
Dual() *dual.Dual
}
// Inferer is anything that can infer given an input.
type Inferer interface {
Infer(a []float32) (policy []float32, value float32, err error)
io.Closer
}
// ExecLogger is anything that can return the execution log.
type ExecLogger interface {
ExecLog() string
}