mathtoolset

package
v0.10.293 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnkonow - unknow error
	ErrUnkonow = errors.New("unknow error")

	// ErrInvalidReel - invalid reel
	ErrInvalidReel = errors.New("invalid reel")

	// ErrInvalidInReelSymbolType - invalid InReelSymbolType
	ErrInvalidInReelSymbolType = errors.New("invalid InReelSymbolType")

	// ErrInvalidReelsStatsExcelFile - invalid ReelsStats excel file
	ErrInvalidReelsStatsExcelFile = errors.New("invalid ReelsStats excel file")

	// ErrInvalidReelsStatsExcelColname - invalid ReelsStats excel colname
	ErrInvalidReelsStatsExcelColname = errors.New("invalid ReelsStats excel colname")

	// ErrNoValidSymbols - no valid symbols
	ErrNoValidSymbols = errors.New("no valid symbols")

	// ErrValidParamInAutoChgWeights - invalid param in AutoChgWeights
	ErrValidParamInAutoChgWeights = errors.New("invalid param in AutoChgWeights")

	// ErrInvalidDataInAGRDataList - invalid data in agrDataList
	ErrInvalidDataInAGRDataList = errors.New("invalid data in agrDataList")

	// ErrNoResultInAutoChgWeights - no result in AutoChgWeights
	ErrNoResultInAutoChgWeights = errors.New("no result in AutoChgWeights")

	// ErrInvalidReelsWithMinOff - invalid reels with minoff
	ErrInvalidReelsWithMinOff = errors.New("invalid reels with minoff")

	// ErrInvalidCode - invalid code
	ErrInvalidCode = errors.New("invalid code")

	// ErrInvalidFunctionParams - invalid function params
	ErrInvalidFunctionParams = errors.New("invalid function params")

	// ErrInvalidTargetRTP - invalid targetRTP
	ErrInvalidTargetRTP = errors.New("invalid targetRTP")

	// ErrUnimplementedCode - unimplemented code
	ErrUnimplementedCode = errors.New("unimplemented code")

	// ErrInvalidScatterNumber - invalid scatter number
	ErrInvalidScatterNumber = errors.New("invalid scatter number")

	ErrCannotBeConverged = errors.New("cannot be converged")
)

Functions

func AutoChgWeights

func AutoChgWeights[T float32 | float64](vw *sgc7game.ValWeights, target T,
	runner FuncRunnerWithValWeights[T], precision int, cmpTarget FuncCmpTarget[T]) (*sgc7game.ValWeights, error)

func AutoChgWeightsEx

func AutoChgWeightsEx[T float32 | float64](vm *sgc7game.FloatValMapping[int, T],
	vw *sgc7game.ValWeights, target T,
	runner FuncRunnerWithValWeights[T], precision int, cmpTarget FuncCmpTarget[T]) (*sgc7game.ValWeights, error)

func AutoGenReels

func AutoGenReels(w, h int, paytables *sgc7game.PayTables, syms []SymbolType, wilds []SymbolType,
	totalBet int, lineNum int) (*sgc7game.ReelsData, error)

func CalcMulLevelRTP added in v0.10.262

func CalcMulLevelRTP(levelRTPs []float64, levelUpProbs []float64, spinNum int, levelUpAddSpinNum []int) float64

计算可升级的rtp,这里只考虑一次升级

func CalcMulLevelRTP2 added in v0.10.268

func CalcMulLevelRTP2(levelRTPs []float64, levelUpProbs []map[int]float64, spinNum int, levelUpAddSpinNum []int) float64

计算可升级的rtp,这里只考虑一次升级

func CalcProbWithWeights

func CalcProbWithWeights(vw *sgc7game.ValWeights2, probs []float64) float64

func CalcScatterProbabilitWithReels added in v0.10.261

func CalcScatterProbabilitWithReels(rd *sgc7game.ReelsData, symbol SymbolType, symbolMapping *SymbolMapping, overlaySyms *sgc7game.ValMapping2, num int, height int) float64

func CalcScatterProbability

func CalcScatterProbability(rss *ReelsStats, symbol SymbolType, num int, height int) float64

func CalcScatterWinsInReels

func CalcScatterWinsInReels(paytables *sgc7game.PayTables, rss *ReelsStats, symbol SymbolType, num int, height int) (int64, error)

CalcScatterWinsInReels -

func CalcSymbolWins

func CalcSymbolWins(rss *ReelsStats, wilds []SymbolType, symbol SymbolType, symbol2 SymbolType, lst []InReelSymbolType) (int64, error)

lst is like [S, W, S+W, No S+W, All]

func CalcSymbolWinsInReelsWithLine

func CalcSymbolWinsInReelsWithLine(paytables *sgc7game.PayTables, rss *ReelsStats, symbols []SymbolType,
	wilds []SymbolType, symbol SymbolType, num int, wildPayoutSymbol SymbolType) (int64, error)

CalcSymbolWinsInReelsWithLine - symbol 不可能是 wild

func CalcWaysWinsInReels

func CalcWaysWinsInReels(paytables *sgc7game.PayTables, rss *ReelsStats, symbol SymbolType, wilds []SymbolType, num int, height int) (int64, error)

CalcWaysWinsInReels -

func CalcWaysWinsInReelsEx

func CalcWaysWinsInReelsEx(paytables *sgc7game.PayTables, rss *ReelsStats, symbol SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, num int, height int) (int64, error)

CalcWaysWinsInReelsEx -

func CheckReels

func CheckReels(reels *sgc7game.ReelsData, minoff int) (int, int, error)

func CountSymbolInReel

func CountSymbolInReel(symbol SymbolType, reel []int, stop int, height int) int

CountSymbolInReel - count symbol number in reel,[stop, stop + height)

func CountSymbolInReelEx

func CountSymbolInReelEx(symbol SymbolType, reel []int, stop int, height int, wilds []SymbolType, symbolMapping *SymbolMapping) int

CountSymbolInReelEx - count symbol number in reel,[stop, stop + height)

func FindSymbol

func FindSymbol(symbols []SymbolType, symbol SymbolType) int

func GenMath

func GenMath(fn string) error

func GenReels

func GenReels(rss *ReelsStats, minoff int, trytimes int) (*sgc7game.ReelsData, error)

纯随机,重复符号需要不重复

func GenReelsMainSymbolsDistance

func GenReelsMainSymbolsDistance(rss *ReelsStats, mainSymbols []SymbolType, minoff int, trytimes int) (*sgc7game.ReelsData, error)

随机,主要符号需要尽量分散开

func HasSymbol

func HasSymbol(symbols []SymbolType, symbol SymbolType) bool

func IsFirstWild

func IsFirstWild(lst []InReelSymbolType, num int) bool

Types

type CodeConfig

type CodeConfig struct {
	Name           string `yaml:"name"`
	Code           string `yaml:"code"`
	DisableAutoRun bool   `yaml:"disableAutoRun"`
}

type Config

type Config struct {
	Type           string          `yaml:"type"`
	Code           string          `yaml:"code"`
	Codes          []*CodeConfig   `yaml:"codes"`
	TargetRTP      float64         `yaml:"targetRTP"`
	Paytables      string          `yaml:"paytables"`
	GenReelsConfig *GenReelsConfig `yaml:"genReelsConfig"`
}

func LoadConfig

func LoadConfig(fn string) (*Config, error)

type FuncCmpTarget

type FuncCmpTarget[T float32 | float64] func(v0 T, v1 T) int

type FuncOnWaysSymbolStats

type FuncOnWaysSymbolStats func(*WaysSymbolStats)

type FuncRunnerWithValWeights

type FuncRunnerWithValWeights[T float32 | float64] func(nvw *sgc7game.ValWeights, isfastmode bool) T

type GenMathMgr

type GenMathMgr struct {
	Paytables     *sgc7game.PayTables
	MapPaytables  map[string]*sgc7game.PayTables
	MapReelsStats map[string]*ReelsStats
	MapReelsData  map[string]*sgc7game.ReelsData
	RTP           float32
	RSS           *ReelsStats
	RetStats      []*SymbolsWinsStats
	Rets          []float64
	MapRets       map[string]float64
	Config        *Config
}

func NewGamMathMgr

func NewGamMathMgr(cfg *Config) *GenMathMgr

func (*GenMathMgr) LoadPaytables

func (mgr *GenMathMgr) LoadPaytables(fn string) error

func (*GenMathMgr) LoadReelsData

func (mgr *GenMathMgr) LoadReelsData(paytablesfn string, fn string, isStrReel bool) (*sgc7game.ReelsData, error)

func (*GenMathMgr) LoadReelsState

func (mgr *GenMathMgr) LoadReelsState(fn string) error

func (*GenMathMgr) RunCode

func (mgr *GenMathMgr) RunCode(i int) error

func (*GenMathMgr) RunCodeEx

func (mgr *GenMathMgr) RunCodeEx(name string) (ref.Val, error)

func (*GenMathMgr) Save

func (mgr *GenMathMgr) Save() error

type GenReelsConfig

type GenReelsConfig struct {
	ReelsStatsFilename string   `yaml:"reelsStatsFilename"`
	ReelsFilename      string   `yaml:"reelsFilename"`
	MainSymbols        []string `yaml:"mainSymbols"`
	Offset             int      `yaml:"offset"`
}

type InReelSymbolType

type InReelSymbolType int
const (
	IRSTypeAll               InReelSymbolType = 0
	IRSTypeSymbol            InReelSymbolType = 1
	IRSTypeWild              InReelSymbolType = 2
	IRSTypeSymbolAndWild     InReelSymbolType = 3
	IRSTypeNoSymbolAndNoWild InReelSymbolType = 4
	IRSTypeNoWild            InReelSymbolType = 5
	IRSTypeNoSymbol          InReelSymbolType = 6
	IRSTypeSymbol2           InReelSymbolType = 7
	IRSTypeSymbol2AndWild    InReelSymbolType = 8
)

func NewInReelSymbolTypeArr

func NewInReelSymbolTypeArr(num int) []InReelSymbolType

type ReelStats

type ReelStats struct {
	MapSymbols     map[SymbolType]*SymbolStats
	TotalSymbolNum int
}

func BuildReelStats

func BuildReelStats(reel []int, mapSymbols *SymbolsMapping) (*ReelStats, error)

func NewReelStats

func NewReelStats() *ReelStats

func (*ReelStats) AddSymbol

func (rs *ReelStats) AddSymbol(symbol SymbolType, num int)

func (*ReelStats) BuildSymbols

func (rs *ReelStats) BuildSymbols(excludeSymbols []SymbolType) []SymbolType

func (*ReelStats) BuildSymbols2

func (rs *ReelStats) BuildSymbols2(excludeSymbols1 []SymbolType, excludeSymbols2 []SymbolType) []SymbolType

func (*ReelStats) BuildSymbolsEx

func (rs *ReelStats) BuildSymbolsEx(symbols []SymbolType) []SymbolType

func (*ReelStats) BuildSymbolsWithWeights

func (rs *ReelStats) BuildSymbolsWithWeights(excludeSymbols []SymbolType) (*sgc7game.ValWeights, error)

func (*ReelStats) BuildSymbolsWithWeights2

func (rs *ReelStats) BuildSymbolsWithWeights2(excludeSymbols1 []SymbolType, excludeSymbols2 []SymbolType) (*sgc7game.ValWeights, error)

func (*ReelStats) BuildSymbolsWithWeightsEx

func (rs *ReelStats) BuildSymbolsWithWeightsEx(symbols []SymbolType) (*sgc7game.ValWeights, error)

func (*ReelStats) Clone

func (rs *ReelStats) Clone() *ReelStats

func (*ReelStats) CountSymbolsNum

func (rs *ReelStats) CountSymbolsNum(symbols []SymbolType) int

func (*ReelStats) GetCanAddSymbols

func (rs *ReelStats) GetCanAddSymbols(symbols []SymbolType) []SymbolType

func (*ReelStats) GetSymbolStats

func (rs *ReelStats) GetSymbolStats(symbol SymbolType) *SymbolStats

func (*ReelStats) GetSymbolWithIndex

func (rs *ReelStats) GetSymbolWithIndex(index int) SymbolType

func (*ReelStats) RemoveSymbol

func (rs *ReelStats) RemoveSymbol(symbol SymbolType, num int) int

type ReelsStats

type ReelsStats struct {
	Reels   []*ReelStats
	Symbols []SymbolType
}

func BuildBasicReelsStats

func BuildBasicReelsStats(reelnum int, paytables *sgc7game.PayTables, excludeSyms []SymbolType) (*ReelsStats, error)

func BuildBasicReelsStatsEx

func BuildBasicReelsStatsEx(reelnum int, syms []SymbolType) (*ReelsStats, error)

func BuildReelsStats

func BuildReelsStats(reels *sgc7game.ReelsData, mapSymbols *SymbolsMapping) (*ReelsStats, error)

func LoadReelsStats

func LoadReelsStats(fn string) (*ReelsStats, error)

func (*ReelsStats) ClearEmptySymbols

func (rss *ReelsStats) ClearEmptySymbols()

func (*ReelsStats) Clone

func (rss *ReelsStats) Clone() *ReelsStats

func (*ReelsStats) CloneWithMapping

func (rss *ReelsStats) CloneWithMapping(mapSymbols *SymbolsMapping) *ReelsStats

func (*ReelsStats) GetNum

func (rss *ReelsStats) GetNum(reelindex int, symbol SymbolType, symbol2 SymbolType,
	wilds []SymbolType, irstype InReelSymbolType) int

func (*ReelsStats) GetReelLength

func (rss *ReelsStats) GetReelLength(reelindex int) int

func (*ReelsStats) GetReelLengthNoSymbol

func (rss *ReelsStats) GetReelLengthNoSymbol(reelindex int, symbol SymbolType, wilds []SymbolType) int

func (*ReelsStats) GetScatterNum

func (rss *ReelsStats) GetScatterNum(reelindex int, symbol SymbolType, irstype InReelSymbolType, height int) int

func (*ReelsStats) GetSymbolNum

func (rss *ReelsStats) GetSymbolNum(reelindex int, symbol SymbolType, wilds []SymbolType) int

func (*ReelsStats) GetSymbolNumNoWild

func (rss *ReelsStats) GetSymbolNumNoWild(reelindex int, symbol SymbolType, wilds []SymbolType) int

func (*ReelsStats) GetWaysNum

func (rss *ReelsStats) GetWaysNum(reelindex int, symbol SymbolType, wilds []SymbolType, irstype InReelSymbolType, height int) int

func (*ReelsStats) GetWaysNumEx

func (rss *ReelsStats) GetWaysNumEx(reelindex int, symbol SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, irstype InReelSymbolType, height int) int

func (*ReelsStats) HasSymbols

func (rss *ReelsStats) HasSymbols(symbol SymbolType) bool

func (*ReelsStats) SaveExcel

func (rss *ReelsStats) SaveExcel(fn string) error

type ScriptCore

type ScriptCore struct {
	Cel *cel.Env
	Ast *cel.Ast
	Prg *cel.Program
}

func NewScriptCore

func NewScriptCore(mgrGenMath *GenMathMgr) (*ScriptCore, error)

func (*ScriptCore) Compile

func (sc *ScriptCore) Compile(code string) error

func (*ScriptCore) Eval

func (sc *ScriptCore) Eval(mgr *GenMathMgr) (ref.Val, error)

type SymbolMapping

type SymbolMapping struct {
	MapSymbols map[SymbolType]SymbolType
}

func NewSymbolMapping

func NewSymbolMapping() *SymbolMapping

func (*SymbolMapping) Has

func (sm *SymbolMapping) Has(dst SymbolType, cur SymbolType) bool

func (*SymbolMapping) HasTarget

func (sm *SymbolMapping) HasTarget(cur SymbolType) bool

func (*SymbolMapping) IsSameKeys

func (sm *SymbolMapping) IsSameKeys(vm *sgc7game.ValMapping2) bool

type SymbolStats

type SymbolStats struct {
	Symbol SymbolType
	Num    int
}

type SymbolType

type SymbolType int

func CloneSymbols

func CloneSymbols(symbols []SymbolType) []SymbolType

func GetSymbols

func GetSymbols(arr []string, paytables *sgc7game.PayTables) []SymbolType

type SymbolWinsStats

type SymbolWinsStats struct {
	Symbol  SymbolType
	WinsNum []int64
	Wins    []int64
	Total   int64
}

func (*SymbolWinsStats) Clone

func (sws *SymbolWinsStats) Clone() *SymbolWinsStats

func (*SymbolWinsStats) IsFine

func (sws *SymbolWinsStats) IsFine() bool

func (*SymbolWinsStats) Merge

func (sws *SymbolWinsStats) Merge(sws1 *SymbolWinsStats)

func (*SymbolWinsStats) MergeWithMulti

func (sws *SymbolWinsStats) MergeWithMulti(sws1 *SymbolWinsStats, multi int)

type SymbolsMapping

type SymbolsMapping struct {
	MapSymbols map[SymbolType]SymbolType
}

func NewSymbolsMapping

func NewSymbolsMapping() *SymbolsMapping

func (*SymbolsMapping) Add

func (mapSymbols *SymbolsMapping) Add(src SymbolType, dest SymbolType)

func (*SymbolsMapping) Has

func (mapSymbols *SymbolsMapping) Has(s SymbolType) bool

type SymbolsWinsFileMode

type SymbolsWinsFileMode int
const (
	SWFModeRTP        SymbolsWinsFileMode = 1
	SWFModeWins       SymbolsWinsFileMode = 2
	SWFModeWinsNum    SymbolsWinsFileMode = 3
	SWFModeWinsNumPer SymbolsWinsFileMode = 4
)

type SymbolsWinsStats

type SymbolsWinsStats struct {
	MapSymbols map[SymbolType]*SymbolWinsStats
	Symbols    []SymbolType
	Num        int
	TotalBet   int64
	TotalWins  int64
}

func AnalyzeReelsScatter

func AnalyzeReelsScatter(paytables *sgc7game.PayTables, reels *sgc7game.ReelsData,
	symbols []SymbolType, mapSymbols *SymbolsMapping, height int) (*SymbolsWinsStats, error)

func AnalyzeReelsScatterEx

func AnalyzeReelsScatterEx(paytables *sgc7game.PayTables, rss *ReelsStats,
	symbols []SymbolType, height int) (*SymbolsWinsStats, error)

func AnalyzeReelsWaysEx

func AnalyzeReelsWaysEx(paytables *sgc7game.PayTables, rss *ReelsStats,
	symbols []SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, height int, bet int, mul int) (*SymbolsWinsStats, error)

AnalyzeReelsWaysEx - totalbet = reels length x mul, wins = symbol wins x mul

func AnalyzeReelsWaysEx2

func AnalyzeReelsWaysEx2(paytables *sgc7game.PayTables, rd *sgc7game.ReelsData,
	symbols []SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, symMul *sgc7game.ValMapping2, overlaySyms *sgc7game.ValMapping2,
	height int, bet int, mul int) (*SymbolsWinsStats, error)

func AnalyzeReelsWaysEx3 added in v0.10.259

func AnalyzeReelsWaysEx3(paytables *sgc7game.PayTables, rd *sgc7game.ReelsData,
	symbols []SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, symMul *sgc7game.ValMapping2, overlaySyms *sgc7game.ValMapping2,
	height int, bet int, mul int) (*SymbolsWinsStats, error)

func AnalyzeReelsWaysSymbolMulti

func AnalyzeReelsWaysSymbolMulti(paytables *sgc7game.PayTables, rss *ReelsStats,
	symbols []SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping, symMul *sgc7game.ValMapping2, height int, bet int, mul int) (*SymbolsWinsStats, error)

AnalyzeReelsWaysSymbolMulti - totalbet = reels length x mul, wins = symbol wins x mul

func AnalyzeReelsWithLine

func AnalyzeReelsWithLine(paytables *sgc7game.PayTables, reels *sgc7game.ReelsData,
	symbols []SymbolType, wilds []SymbolType, mapSymbols *SymbolsMapping, betMul int, lineNum int) (*SymbolsWinsStats, error)

func AnalyzeReelsWithLineEx

func AnalyzeReelsWithLineEx(paytables *sgc7game.PayTables, rss *ReelsStats,
	symbols []SymbolType, wilds []SymbolType, betMul int, lineNum int) (*SymbolsWinsStats, error)

func NewSymbolsWinsStats

func NewSymbolsWinsStats(num int) *SymbolsWinsStats

func (*SymbolsWinsStats) Clone

func (ssws *SymbolsWinsStats) Clone() *SymbolsWinsStats

func (*SymbolsWinsStats) CountRTP

func (ssws *SymbolsWinsStats) CountRTP() float64

func (*SymbolsWinsStats) GetSymbolWinsStats

func (ssws *SymbolsWinsStats) GetSymbolWinsStats(symbol SymbolType) *SymbolWinsStats

func (*SymbolsWinsStats) IsFine

func (ssws *SymbolsWinsStats) IsFine() bool

func (*SymbolsWinsStats) Merge

func (ssws *SymbolsWinsStats) Merge(ssws1 *SymbolsWinsStats)

func (*SymbolsWinsStats) MergeWithMulti

func (ssws *SymbolsWinsStats) MergeWithMulti(ssws1 *SymbolsWinsStats, multi int)

func (*SymbolsWinsStats) SaveExcel

func (ssws *SymbolsWinsStats) SaveExcel(fn string, fms []SymbolsWinsFileMode) error

func (*SymbolsWinsStats) SaveExcelSheet

func (ssws *SymbolsWinsStats) SaveExcelSheet(f *excelize.File, fm SymbolsWinsFileMode) error

type WaysReelStats

type WaysReelStats struct {
	MapSymbols     map[int]*WaysSymbolStats
	TotalSymbolNum int
}

func (*WaysReelStats) EachSymbol

func (wrs *WaysReelStats) EachSymbol(symbol SymbolType, onEach FuncOnWaysSymbolStats)

func (*WaysReelStats) GetNumWithSymbolNumInWindow

func (wrs *WaysReelStats) GetNumWithSymbolNumInWindow(symbol SymbolType, numInWindow int) int

func (*WaysReelStats) GetSymbolKeys

func (wrs *WaysReelStats) GetSymbolKeys(symbol SymbolType) []int

func (*WaysReelStats) GetSymbolStats

func (wrs *WaysReelStats) GetSymbolStats(symbol SymbolType, numInWindow int) *WaysSymbolStats

type WaysReelsStats

type WaysReelsStats struct {
	Reels   []*WaysReelStats
	Symbols []SymbolType
	Keys    []int
	Height  int
}

func BuildWaysReelsStats

func BuildWaysReelsStats(rd *sgc7game.ReelsData, height int) *WaysReelsStats

func BuildWaysReelsStatsEx

func BuildWaysReelsStatsEx(rd *sgc7game.ReelsData, height int, symbols []SymbolType, wilds []SymbolType, symbolMapping *SymbolMapping) *WaysReelsStats

BuildWaysReelsStatsEx - 只计算symbols里的symbol,且把wild直接计算进去

func NewWaysReelsStats

func NewWaysReelsStats(height int) *WaysReelsStats

func (*WaysReelsStats) GetNonWaysNum

func (wrss *WaysReelsStats) GetNonWaysNum(reelindex int, symbol SymbolType) int

func (*WaysReelsStats) SaveExcel

func (wrss *WaysReelsStats) SaveExcel(fn string) error

type WaysSymbolStats

type WaysSymbolStats struct {
	Symbol      SymbolType
	NumInWindow int
	Num         int
}

Jump to

Keyboard shortcuts

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