Documentation
¶
Index ¶
- func EncodeTwoPlayerBoard(a []game.Colour, prealloc []float32) []float32
- func MakeIterator(board []float32, m, n int) (retVal [][]float32)
- func ReturnIterator(m, n int, it [][]float32)
- func RotateBoard(board []float32, m, n int) ([]float32, error)
- func WQEncoder(a game.State) []float32
- type AZ
- type Agent
- type Arena
- func (a *Arena) Epoch() int
- func (a *Arena) GameNumber() int
- func (a *Arena) Log(w io.Writer)
- func (a *Arena) Name() string
- func (a *Arena) Play(record bool, enc OutputEncoder, aug Augmenter) (winner game.Player, examples []Example)
- func (a *Arena) Score(p game.Player) float64
- func (a *Arena) State() game.State
- type Augmenter
- type Config
- type Dualer
- type Example
- type ExecLogger
- type GameEncoder
- type Inferer
- type OutputEncoder
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeTwoPlayerBoard ¶
EncodeTwoPlayerBoard encodes black as 1, white as -1 for each stone placed
func MakeIterator ¶
MakeIterator makes a generic iterator of a board
func ReturnIterator ¶
Types ¶
type AZ ¶
type AZ struct { // state Arena Statistics // contains filtered or unexported fields }
AZ is the top level structure and the entry point of the API. It it a wrapper around the MTCS and the NeeuralNework that composes the algorithm. AZ stands for AlphaZero
func New ¶
New AlphaZero structure. It takes a game state (implementing the board, rules, etc.) and a configuration to apply to the MCTS and the neural network
func (*AZ) Learn ¶
Learn learns for iters. It self-plays for episodes, and then trains a new NN from the self play example.
type Agent ¶
type Agent struct { NN *dual.Dual MCTS *mcts.MCTS Player game.Player Enc GameEncoder // Statistics Wins float32 Loss float32 Draw float32 sync.Mutex // contains filtered or unexported fields }
An Agent is a player, AI or Human
func (*Agent) Infer ¶
Infer infers a bunch of moves based on the game state. This is mainly used to implement a Inferer such that the MCTS search can use it.
type Arena ¶
type Arena struct {
A, B *Agent
// contains filtered or unexported fields
}
Arena represents a game arena Arena fulfils the interface game.MetaState
func MakeArena ¶
func MakeArena(g game.State, a, b Dualer, conf mcts.Config, enc GameEncoder, aug Augmenter, name string) Arena
MakeArena makes an arena given a game.
func NewArena ¶
func NewArena(g game.State, a, b Dualer, conf mcts.Config, enc GameEncoder, aug Augmenter, name string) *Arena
NewArena makes an arena an returns a pointer to the Arena
type Config ¶
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 }
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 Dualer ¶
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 ExecLogger ¶
type ExecLogger interface {
ExecLog() string
}
ExecLogger is anything that can return the execution log.
type GameEncoder ¶
GameEncoder encodes a game state as a slice of floats
type Inferer ¶
type Inferer interface { Infer(a []float32) (policy []float32, value float32, err error) io.Closer }
Inferer is anything that can infer given an input.
type OutputEncoder ¶
OutputEncoder encodes the entire meta state as whatever.
An example OutputEncoder is the GifEncoder. Another example would be a logger.