equity

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PEGAdjustmentFilename = "preendgame.json"
	LeavesFilename        = "leaves.klv2"
)
View Source
const MaxRepresentedWinSpread = 300

Variables

This section is empty.

Functions

func LeaveCacheLoadFunc

func LeaveCacheLoadFunc(cfg *wglconfig.Config, key string) (interface{}, error)

func PEGCacheLoadFunc

func PEGCacheLoadFunc(cfg *wglconfig.Config, key string) (interface{}, error)

func WinPCTLoadFunc

func WinPCTLoadFunc(cfg *wglconfig.Config, key string) (interface{}, error)

Types

type BlankLeaves

type BlankLeaves struct{}

func (*BlankLeaves) LeaveValue

func (b *BlankLeaves) LeaveValue(leave tilemapping.MachineWord) float64

type CombinedStaticCalculator

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

CombinedStaticCalculator is a redundant struct that combines the function of several calculators. It is only here for speed purposes.

func NewCombinedStaticCalculator

func NewCombinedStaticCalculator(lexiconName string,
	cfg *config.Config, leaveFilename, pegfile string) (
	*CombinedStaticCalculator, error)

func (CombinedStaticCalculator) Equity

func (csc CombinedStaticCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (CombinedStaticCalculator) LeaveValue

func (CombinedStaticCalculator) Type added in v0.11.0

func (csc CombinedStaticCalculator) Type() string

type EndgameAdjustmentCalculator

type EndgameAdjustmentCalculator struct{}

EndgameAdjustmentCalculator returns an equity adjustment for endgame plays. It should only be used if the bag is empty. Note that it doesn't solve the endgame; this should only be used for simulation estimates!

func (EndgameAdjustmentCalculator) Equity

func (eac EndgameAdjustmentCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (EndgameAdjustmentCalculator) Type added in v0.11.0

Type returns the type of the equity calculator.

type EquityCalculator

type EquityCalculator interface {
	// Equity is a catch-all term for most post-score adjustments that
	// need to be made. It includes first-turn placement heuristic,
	// leave calculations, any pre-endgame timing heuristics, and more.
	Equity(play *move.Move, board *board.GameBoard, bag *tilemapping.Bag,
		oppRack *tilemapping.Rack) float64
	Type() string
}

EquityCalculator is a calculator of equity.

type ExhaustiveLeaveCalculator

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

ExhaustiveLeaveCalculator should apply an equity calculation for all leaves exhaustively.

func NewExhaustiveLeaveCalculator

func NewExhaustiveLeaveCalculator(lexiconName string,
	cfg *config.Config, leaveFilename string) (
	*ExhaustiveLeaveCalculator, error)

func (ExhaustiveLeaveCalculator) Equity

func (els ExhaustiveLeaveCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (ExhaustiveLeaveCalculator) LeaveValue

func (ExhaustiveLeaveCalculator) Type added in v0.11.0

func (els ExhaustiveLeaveCalculator) Type() string

Type returns the type of the equity calculator.

type KLV added in v0.6.0

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

KLV is a Kurnia Leave Value file. It contains a KWG and a list of float32 leave values. We convert to float64 for our internal structures.

func ReadKLV added in v0.6.0

func ReadKLV(file io.Reader) (*KLV, error)

func (*KLV) LeaveValue added in v0.6.0

func (k *KLV) LeaveValue(leave tilemapping.MachineWord) float64

type Leaves

type Leaves interface {
	LeaveValue(leave tilemapping.MachineWord) float64
}

type NoLeaveCalculator

type NoLeaveCalculator struct{}

NoLeaveCalculator does not take leave into account at all.

func NewNoLeaveCalculator

func NewNoLeaveCalculator() *NoLeaveCalculator

func (*NoLeaveCalculator) Equity

func (nls *NoLeaveCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (*NoLeaveCalculator) LeaveValue

func (nls *NoLeaveCalculator) LeaveValue(leave tilemapping.MachineWord) float64

func (*NoLeaveCalculator) Type added in v0.11.0

func (nls *NoLeaveCalculator) Type() string

type OpeningAdjustmentCalculator

type OpeningAdjustmentCalculator struct{}

OpeningAdjustmentCalculator returns an equity adjustment for an opening play. It should only be used if the board is empty.

func (OpeningAdjustmentCalculator) Equity

func (oac OpeningAdjustmentCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (OpeningAdjustmentCalculator) Type added in v0.11.0

type PreEndgameAdjustmentCalculator

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

PreEndgameAdjustmentCalculator returns an equity adjustment for preendgame plays. It should only be used if the bag is nearly empty. Note that it doesn't solve pre-endgames; this should only be used for simulation estimates!

func NewPreEndgameAdjustmentCalculator

func NewPreEndgameAdjustmentCalculator(cfg *config.Config, lexiconName string, pegfile string) (*PreEndgameAdjustmentCalculator, error)

func (PreEndgameAdjustmentCalculator) Equity

func (pac PreEndgameAdjustmentCalculator) Equity(play *move.Move, board *board.GameBoard,
	bag *tilemapping.Bag, oppRack *tilemapping.Rack) float64

func (PreEndgameAdjustmentCalculator) Type added in v0.11.0

Jump to

Keyboard shortcuts

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