game

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlgList     = []*AlgInfo{}
	InfoMap     = map[string]*GameInfo{}
	GameFactory = map[string]func() Gamble{}
	ScanFactory = map[string]Scanner{}
)
View Source
var (
	Year = util.Year
	Date = util.Date
)
View Source
var (
	ErrNoObj   = errors.New("unknown object id")
	ErrAidHas  = errors.New("algorithm ID already declared")
	ErrLNumOut = errors.New("declared LNum is out of algorithm bel lines set")
)
View Source
var DataRouter = map[string]any{} // object router for data loading
View Source
var FiltMap = map[string]Filter{
	"all":  func(gi *GameInfo) bool { return true },
	"slot": func(gi *GameInfo) bool { return gi.GT == GTslot },
	"keno": func(gi *GameInfo) bool { return gi.GT == GTkeno },

	"agt":        func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "agt" },
	"aristocrat": func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "aristocrat" },
	"ct":         func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "ct" || util.ToID(gi.Prov) == "ctinteractive" },
	"betsoft":    func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "betsoft" },
	"igt":        func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "igt" },
	"megajack":   func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "megajack" },
	"netent":     func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "netent" },
	"novomatic":  func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "novomatic" },
	"playngo":    func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "playngo" },
	"playtech":   func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "playtech" },
	"slotopol":   func(gi *GameInfo) bool { return util.ToID(gi.Prov) == "slotopol" },

	"lines":  func(gi *GameInfo) bool { return gi.LN > 0 },
	"ways":   func(gi *GameInfo) bool { return gi.WN > 0 },
	"bon":    func(gi *GameInfo) bool { return gi.BN > 0 },
	"lpay":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPlpay == GPlpay },
	"rpay":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPrpay == GPrpay },
	"apay":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPapay == GPapay },
	"cpay":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPcpay == GPcpay },
	"jack":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPjack > 0 },
	"fill":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfill > 0 },
	"mix":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPmix > 0 },
	"bm":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPbmode > 0 },
	"um":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPpick > 0 },
	"casc":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPcasc > 0 },
	"cm":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPcmult > 0 },
	"fg":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgany > 0 },
	"fgo":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgonce > 0 },
	"fgt":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgtwic > 0 },
	"fgs":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgseq > 0 },
	"fgr":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgreel > 0 },
	"fgm":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPfgmult > 0 },
	"sany":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPscany > 0 },
	"scat":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPscat > 0 },
	"wany":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPwany > 0 },
	"wild":   func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPwild > 0 },
	"wsc":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPwsc > 0 },
	"rw":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPrwild > 0 },
	"bw":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPbwild > 0 },
	"ew":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPewild > 0 },
	"wt":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPwturn > 0 },
	"wm":     func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPwmult > 0 },
	"big":    func(gi *GameInfo) bool { return gi.GT == GTslot && gi.GP&GPbsym > 0 },
	"nodate": func(gi *GameInfo) bool { return gi.Date == 0 },
}
View Source
var LoadMap = [][]byte{} // storage for loaded data

Functions

func MakeRtpList added in v0.5.0

func MakeRtpList[T any](reelsmap map[float64]T) []float64

func MustReadChain added in v0.11.0

func MustReadChain(r io.Reader)

MustReadChain is like ReadChain but panics if an error occurs.

func Passes added in v0.11.0

func Passes(gi *GameInfo, finclist, fexclist [][]Filter) bool

func ReadChain added in v0.11.0

func ReadChain(r io.Reader) (err error)

ReadChain reads and decodes a sequence of objects from a stream. Each object is identified by a string id, followed by its YAML representation. The objects are looked up in the DataRouter map. If an object implements the Clearer interface, its Clear method is called before decoding.

Types

type AlgDescr added in v0.10.0

type AlgDescr struct {
	GT  GT        `json:"gt,omitempty" yaml:"gt,omitempty" xml:"gt,omitempty"` // game type
	GP  GP        `json:"gp,omitempty" yaml:"gp,omitempty" xml:"gp,omitempty"` // game properties
	SX  int       `json:"sx,omitempty" yaml:"sx,omitempty" xml:"sx,omitempty"` // grid width
	SY  int       `json:"sy,omitempty" yaml:"sy,omitempty" xml:"sy,omitempty"` // grid height
	SN  int       `json:"sn,omitempty" yaml:"sn,omitempty" xml:"sn,omitempty"` // number of symbols
	LN  int       `json:"ln,omitempty" yaml:"ln,omitempty" xml:"ln,omitempty"` // number of lines in bet lines set
	WN  int       `json:"wn,omitempty" yaml:"wn,omitempty" xml:"wn,omitempty"` // number of ways
	BN  int       `json:"bn,omitempty" yaml:"bn,omitempty" xml:"bn,omitempty"` // number of bonuses
	RTP []float64 `json:"rtp" yaml:"rtp,flow" xml:"rtp"`                       // 'Return to Player' percents list
}

func (*AlgDescr) FindClosest added in v0.10.0

func (ad *AlgDescr) FindClosest(mrtp float64) (rtp float64)

type AlgInfo added in v0.10.0

type AlgInfo struct {
	Aliases  []GameAlias `json:"aliases" yaml:"aliases" xml:"aliases"`
	AlgDescr `yaml:",inline"`
	Update   func(ai *AlgInfo) `json:"-" yaml:"-" xml:"-"` // closure to update fields
}

func (*AlgInfo) SetupFactory added in v0.10.0

func (ai *AlgInfo) SetupFactory(game func(int) Gamble, scan Scanner)

type CM added in v0.13.0

type CM uint // Calculations method
const (
	CMbruteforce CM = iota + 1
	CMmontecarlo
	CMcombinatorics
)

type Filter added in v0.11.0

type Filter func(*GameInfo) bool

func GetFilter added in v0.11.0

func GetFilter(key string) Filter

type GP added in v0.7.0

type GP uint // Game properties
const (
	GPlpay GP = 1<<(iota+1) - 1 // pays left to right
	GPrpay                      // pays left to right and right to left
	GPapay                      // pays for combination at any position
	GPcpay GP = 1 << iota       // pays by clusters

	GPlsel // user can select bet lines
	GPwsel // user can change ways set

	GPjack  // cumulative jackpot is present
	GPfill  // has multiplier on filled grid
	GPmix   // has pays by combinations with mixed symbols (non-wilds)
	GPcumul // has cumulative pays (in this case spin can fails if bank have not enough money)

	GPbmode // has non-reels bonus mode
	GPpick  // has game mode depending on the user's choice
	GPcasc  // cascade falls present
	GPcmult // multipliers on cascade avalanche

	GPfgonce // non-retriggered free games are present
	GPfgtwic // free games that can be retriggered only once
	GPfgseq  // free games that can be retriggered in a sequence
	GPfgreel // separate reels on free games

	GPrgmult // any multipliers on regular games
	GPfgmult // any multipliers on free games
	GPscat   // has scatters
	GPstscat // has stacked scatters (several may appear on the reel)

	GPwsc   // has wild/scatters symbols
	GPwild  // has wild symbols
	GPrwild // has reel wild symbols
	GPbwild // has big (3x3) wild symbols

	GPewild // has expanding wilds
	GPwturn // symbols turns to wilds
	GPwmult // has multiplier on wilds
	GPbsym  // has big symbol reel (usually with 3x3 in the center on free games)

	// free games are absent
	GPfgno GP = 0
	// any free games
	GPfgany GP = GPfgonce | GPfgtwic | GPfgseq
	// any wild symbols
	GPwany GP = GPwsc | GPwild | GPrwild | GPbwild | GPewild
	// any scatter symbols
	GPscany GP = GPwsc | GPscat | GPstscat
)

type GT added in v0.10.0

type GT uint // Game type
const (
	GTslot GT = 1 + iota
	GTkeno
)

type Gamble added in v0.11.0

type Gamble interface {
	Spin(float64)         // fill the grid with random hits on reels closest to given RTP, constant function
	GetBet() float64      // returns current bet, constant function
	SetBet(float64) error // set bet to given value
}

type GameAlias added in v0.5.0

type GameAlias struct {
	Prov string    `json:"prov" yaml:"prov" xml:"prov"`                               // game provider
	Name string    `json:"name" yaml:"name" xml:"name"`                               // game name
	LNum int       `json:"lnum,omitempty" yaml:"lnum,omitempty" xml:"lnum,omitempty"` // maximum number of selectable lines
	Date util.Unix `json:"date,omitempty" yaml:"date,omitempty" xml:"date,omitempty"` // game release date
}

GameAlias structure describes the game target of algorithm. Several games can shares single algorithm, and in this case all those games presents in the list of aliases for this algorithm. All game rules, paytables and lines should be equal for this games, except maximum number of selected lines can differ. If maximum number of lines differ, algorithm receives largest number.

type GameInfo added in v0.5.0

type GameInfo struct {
	GameAlias `yaml:",inline"`
	*AlgDescr `yaml:",inline"`
}

type ScanPar added in v0.13.0

type ScanPar struct {
	Method CM      // calculations method ID
	TN     int     // threads number (0 to use all hardware available cores)
	Total  uint64  // number of total spins
	Prec   float64 // expected precision for Monte Carlo method
	Conf   float64 // confidence (for Z, VI, CI)
	MRTP   float64 // master RTP
	Sel    int     // number of selected bet lines
}

type Scanner added in v0.6.0

type Scanner func(context.Context, *ScanPar) float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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