montecarlo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: GPL-3.0 Imports: 25 Imported by: 2

Documentation

Overview

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

Index

Constants

View Source
const IterationsCutoff = 2000
View Source
const MinReasonableWProb = 0.005 // or 0.5%
View Source
const PerPlyStopScaling = 625
View Source
const SimilarPlaysIterationsCutoff = 750
View Source
const StopConditionCheckInterval = 128

Variables

This section is empty.

Functions

This section is empty.

Types

type InferenceMode added in v0.5.0

type InferenceMode int
const (
	InferenceOff InferenceMode = iota
	InferenceCycle
	InferenceRandom
)

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.
	WinRatio float64   `json:"win,omitempty" yaml:"win,omitempty"`
	Plies    []LogPlay `json:"plies,omitempty" yaml:"plies,omitempty,flow"`
}

LogPlay is a single play.

type SimmedPlay

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

func (*SimmedPlay) Ignore added in v0.5.0

func (sp *SimmedPlay) Ignore()

func (*SimmedPlay) Move added in v0.5.0

func (s *SimmedPlay) Move() *move.Move

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, eqCalcs []equity.EquityCalculator,
	leaves equity.Leaves, cfg *config.Config)

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) error

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) SetInferences added in v0.5.0

func (s *Simmer) SetInferences(i [][]tilemapping.MachineLetter, mode InferenceMode)

func (*Simmer) SetKnownOppRack added in v0.5.0

func (s *Simmer) SetKnownOppRack(r []tilemapping.MachineLetter)

func (*Simmer) SetLogStream

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

func (*Simmer) SetStoppingCondition added in v0.5.0

func (s *Simmer) SetStoppingCondition(sc StoppingCondition)

func (*Simmer) SetThreads

func (s *Simmer) SetThreads(threads int)

func (*Simmer) SimSingleThread added in v0.8.2

func (s *Simmer) SimSingleThread(iters int)

func (*Simmer) Simulate

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

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

func (*Simmer) Threads added in v0.8.7

func (s *Simmer) Threads() int

func (*Simmer) TrimBottom added in v0.4.2

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

func (*Simmer) WinningPlay added in v0.8.7

func (s *Simmer) WinningPlay() *SimmedPlay

type StoppingCondition added in v0.5.0

type StoppingCondition int
const (
	StopNone StoppingCondition = iota
	Stop95
	Stop98
	Stop99
)

Jump to

Keyboard shortcuts

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