keno

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBetEmpty      = errors.New("bet is empty")
	ErrKenoNotEnough = errors.New("no pays with this selected numbers")
	ErrKenoTooMany   = errors.New("too many numbers selected, not more than 10 expected")
	ErrKenoOutRange  = errors.New("some of given number is out of range 1..80")
)
View Source
var C_80_20 = Combin(80, 20)
View Source
var MakeBitNum = util.MakeBitNum128

Functions

func Combin

func Combin(n, r int) float64

func Prob

func Prob(n, r int) float64

Types

type Bitset

type Bitset = util.Bitset128

type KS

type KS byte

Keno spot type

const (
	KSempty  KS = 0             // empty cell
	KSsel    KS = 0x1           // cell with selection without hit
	KShit    KS = 0x2           // cell with hit without selection
	KSselhit KS = KSsel | KShit // win cell, hit and selection
)

type Keno80

type Keno80 struct {
	Scr Screen  `json:"scr" yaml:"scr" xml:"scr"` // game screen
	Bet float64 `json:"bet" yaml:"bet" xml:"bet"` // bet value
	Sel Bitset  `json:"sel" yaml:"sel" xml:"sel"` // selected numbers
}

func (*Keno80) CheckSel added in v0.5.0

func (g *Keno80) CheckSel(sel Bitset, kp *Paytable) error

func (*Keno80) GetBet

func (g *Keno80) GetBet() float64

func (*Keno80) GetSel

func (g *Keno80) GetSel() Bitset

func (*Keno80) SetBet

func (g *Keno80) SetBet(bet float64) error

func (*Keno80) Spin

func (g *Keno80) Spin(_ float64)

type KenoGame

type KenoGame interface {
	Scanner(*Wins)        // scan given screen and append result to wins, constat function
	Spin(float64)         // fill the screen with random hits on reels closest to given RTP, constat function
	GetBet() float64      // returns current bet, constat function
	SetBet(float64) error // set bet to given value
	GetSel() Bitset       // returns current selected numbers, constat function
	SetSel(Bitset) error  // set current selected numbers
}

KenoGame is common keno interface. Any keno game should implement this interface.

type Paytable

type Paytable [11][11]float64

func (*Paytable) CalcStat added in v0.5.0

func (kp *Paytable) CalcStat(ctx context.Context) float64

func (*Paytable) HasSel added in v0.5.0

func (kp *Paytable) HasSel(sel int) bool

func (*Paytable) Pay

func (kp *Paytable) Pay(sel, hit int) float64

func (*Paytable) Scanner added in v0.5.0

func (kp *Paytable) Scanner(scrn *Screen, wins *Wins, bet float64)

type Screen

type Screen [80]KS

type Wins

type Wins struct {
	Sel int     `json:"sel" yaml:"sel" xml:"sel,attr"`
	Num int     `json:"num" yaml:"num" xml:"num,attr"`
	Pay float64 `json:"pay" yaml:"pay" xml:"pay,attr"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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