montecarlo

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2020 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Overview

Package montecarlo implements truncated monte-carlo search during the regular game. In other words, "simming".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogIteration

type LogIteration struct {
	Iteration int       `json:"iteration" yaml:"iteration"`
	Plays     []LogPlay `json:"plays" yaml:"plays"`
	Thread    int       `json:"thread" yaml:"thread"`
}

LogIteration is a struct meant for serializing to a log-file, for debug and other purposes.

type LogPlay

type LogPlay struct {
	Play string `json:"play" yaml:"play"`
	Rack string `json:"rack" yaml:"rack"`
	Pts  int    `json:"pts" yaml:"pts"`
	// Leftover is the equity of the leftover tiles at the end of the sim.
	Leftover float64 `json:"left,omitempty" yaml:"left,omitempty"`
	// Although this is a recursive structure we don't really use it
	// recursively.
	Plies []LogPlay `json:"plies,omitempty" yaml:"plies,omitempty,flow"`
}

LogPlay is a single play.

type SimmedPlay

type SimmedPlay struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*SimmedPlay) String

func (sp *SimmedPlay) String() string

type Simmer

type Simmer struct {
	// contains filtered or unexported fields
}

Simmer implements the actual look-ahead search

func (*Simmer) EquityStats

func (s *Simmer) EquityStats() string

func (*Simmer) Init

func (s *Simmer) Init(game *game.Game, aiplayer player.AIPlayer)

func (*Simmer) IsSimming

func (s *Simmer) IsSimming() bool

func (*Simmer) Iterations

func (s *Simmer) Iterations() int

func (*Simmer) PrepareSim added in v0.4.2

func (s *Simmer) PrepareSim(plies int, plays []*move.Move)

PrepareSim resets all the stats before a simulation.

func (*Simmer) Ready added in v0.4.2

func (s *Simmer) Ready() bool

func (*Simmer) Reset added in v0.4.2

func (s *Simmer) Reset()

func (*Simmer) ScoreDetails

func (s *Simmer) ScoreDetails() string

func (*Simmer) SetLogStream

func (s *Simmer) SetLogStream(l io.Writer)

func (*Simmer) SetThreads

func (s *Simmer) SetThreads(threads int)

func (*Simmer) Simulate

func (s *Simmer) Simulate(ctx context.Context) error

Simulate sims all the plays. It is a blocking function.

func (*Simmer) TrimBottom added in v0.4.2

func (s *Simmer) TrimBottom(totrim int) error

type Statistic

type Statistic struct {
	// contains filtered or unexported fields
}

Statistic contains statistics per move

func (*Statistic) Mean added in v0.4.2

func (s *Statistic) Mean() float64

func (*Statistic) Push added in v0.4.2

func (s *Statistic) Push(val float64)

func (*Statistic) Stdev added in v0.4.2

func (s *Statistic) Stdev() float64

func (*Statistic) Variance added in v0.4.2

func (s *Statistic) Variance() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL