tripled

package module
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 7 Imported by: 0

README

About

Go implementation of Triple Diamond slots.

Documentation

Overview

Package tripled implements Triple Diamond slots logic.

Example
package main

import (
	"fmt"
	"math/rand"

	"github.com/cardrank/tripled"
)

func main() {
	for i, seed := range []int64{
		507,
		2931,
		4981,
		7689,
		9085,
		12415,
		16614,
		18623,
	} {
		if i != 0 {
			fmt.Println("---------")
		}
		fmt.Println("seed:", seed)
		// note: use a real rng source
		r := rand.New(rand.NewSource(seed))
		res, err := tripled.DefaultDist.Spin(r, 9)
		if err != nil {
			panic(err)
		}
		fmt.Println(res)
	}
}
Output:

seed: 507
pos: 1 12 17
∙∙=
-=∙
∙∙-
payout: 0x
---------
seed: 2931
pos: 12 19 17
===
∙∙∙
-∙-
lines:
 2 pays 20x
payout: 20x
---------
seed: 4981
pos: 21 15 15
∙=-
◆∙∙
∙≡=
lines:
 1 pays 2x
 6 pays 2x
 7 pays 2x
payout: 6x
---------
seed: 7689
pos: 7 0 8
∙◆∙
≡∙≡
∙∙∙
lines:
 2 pays 2x
 6 pays 120x
payout: 122x
---------
seed: 9085
pos: 16 11 11
777
∙∙∙
-=-
lines:
 2 pays 100x
 3 pays 5x
payout: 105x
---------
seed: 12415
pos: 0 21 0
◆∙◆
∙◆∙
-∙∙
lines:
 1 pays 2x
 2 pays 10x
 4 pays 10x
 5 pays 90x
 8 pays 2x
 9 pays 1199x
payout: 1313x
---------
seed: 16614
pos: 0 21 1
◆∙∙
∙◆∙
-∙-
lines:
 1 pays 2x
 2 pays 2x
 4 pays 90x
 5 pays 2x
 8 pays 30x
 9 pays 10x
payout: 136x
---------
seed: 18623
pos: 7 9 6
∙≡∙
≡∙-
∙7∙
lines:
 6 pays 5x
payout: 5x

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultDist = NewDist(DefaultPayout)

DefaultDist is the default dist.

View Source
var DefaultPayout = 0.97

DefaultPayout is the default payout.

View Source
var DefaultShuffles = 3

DefaultShuffles is the default shuffles.

View Source
var Lines = [9]int{
	0: cw | cc | ce,
	1: nw | nc | ne,
	2: sw | sc | se,
	3: nw | cc | se,
	4: sw | cc | ne,
	5: cw | nc | ce,
	6: cw | sc | ce,
	7: sw | cc | se,
	8: nw | cc | ne,
}

Lines are pay line masks.

Reels are reels of slot symbols.

Functions

func Payout

func Payout(mask int, line ...Symbol) int

Payout determines the payout for matching line symbols based on the bit mask.

func SymbolsString added in v0.1.5

func SymbolsString(pos ...int) string

SymbolsString returns the symbols as a string.

Types

type Dist added in v0.2.0

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

Dist is a dist.

func NewDist added in v0.2.0

func NewDist(rtp float64) *Dist

NewDist creates a dist with the specified return-to-player (RTP) value.

func (*Dist) Spin added in v0.2.0

func (d *Dist) Spin(r Rand, lines int) (Result, error)

Spin spins the reels.

type Error

type Error string

Error is an error.

const (
	// ErrInvalidLines is the invalid lines error.
	ErrInvalidLines Error = "invalid lines"
)

Errors.

func (Error) Error

func (err Error) Error() string

Error satisfies the [error] interface.

type Rand

type Rand interface {
	Intn(n int) int
}

Rand is the shared random interface.

type Result

type Result struct {
	Pos    []int       `json:"pos"`
	Lines  map[int]int `json:"lines"`
	Payout int         `json:"payout"`
}

Result is a spin result.

func NewResult

func NewResult(lines int, pos ...int) Result

NewResult creates a result with the specified reel positions.

func Spin

func Spin(r Rand, lines int) (Result, error)

Spin spins the reels, calculating the results for the spin.

func (Result) Format

func (res Result) Format(f fmt.State, _ rune)

Format satisfies the fmt.Formatter interface.

func (Result) Symbols

func (res Result) Symbols() string

Symbols produces a string representing the final view of the result.

type Symbol

type Symbol int

Symbol is a slot symbol.

const (
	Blank Symbol = iota
	Bar1
	Bar2
	Bar3
	Seven
	Diamond
)

Symbols.

func Symbols

func Symbols(pos ...int) []Symbol

Symbols returns the symbols in the positions.

func (Symbol) Format

func (s Symbol) Format(f fmt.State, verb rune)

Format satisfies the fmt.Formatter interface.

func (Symbol) Name

func (s Symbol) Name() string

Name returns the symbol name.

func (Symbol) Rune

func (s Symbol) Rune() rune

Rune returns the symbol rune.

Directories

Path Synopsis
cmd
tdfind
Command tdfind finds triple diamond seeds.
Command tdfind finds triple diamond seeds.
tripled
Command tripled is a command-line implementation of Triple Diamond slots.
Command tripled is a command-line implementation of Triple Diamond slots.

Jump to

Keyboard shortcuts

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