random

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Probability

func Probability(per int, args ...int) bool

Probability 独立概率,args单位,默认万分比,,,百分比传入100

func Relative

func Relative(items map[int32]int32) int32

Relative 相对概率,权重

func RelativeMulti

func RelativeMulti(items map[int32]int32, num int, repeat ...bool) []int32

RelativeMulti 相对概率,权重 返回多个,repeat 是否可以重复

func Roll

func Roll(a, b int) int

Types

type Random

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

func New

func New(items map[int32]int32) *Random

func (*Random) Multi

func (this *Random) Multi(num int) (r []int32)

Multi 随机多个不重复

func (*Random) Roll

func (this *Random) Roll() int32

Jump to

Keyboard shortcuts

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