weight

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUnits

func NewUnits(str string) ([][]int, error)

func SelectOne

func SelectOne(weights ...int) int

func ValidateUnits

func ValidateUnits(str string) error

Types

type Calculator

type Calculator struct {
	Units   []*Unit
	Weights []int
}

func NewCalculator

func NewCalculator(units [][]int) (*Calculator, error)

0~9 50%概率,10~19 30%概率,20~39 20%概率 input [[0,9,50],[10,19,30],[20,39,20]]

func (Calculator) Calculate

func (this Calculator) Calculate() (idx int, value int)

func (Calculator) GetUnit

func (this Calculator) GetUnit() *Unit

type Unit

type Unit struct {
	From        int
	To          int
	Probability int
}

Jump to

Keyboard shortcuts

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