github.com/gorgonia/agogo@v0.1.1/datatypes.go (about)

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