Skip to content

Picker is a package that randomly picks an element based on its weight

License

Notifications You must be signed in to change notification settings

barbosaigor/picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Picker

Picker implements an algorithm that randomly selects an element, taking into account each element probability. Higher weight elements are more likely to be choosen.

Documentation

Add attaches an element.

Element Weight
A 80
B 90
C 10
p := picker.New()
p.Add("a", 80)
p.Add("b", 90)
p.Add("c", 10)

Roll Dice selects a random element taking into account each element probability. Higher weight elements are more likely to be choosen.

p := picker.New()
p.Add("a", 80)
p.Add("b", 90)
p.Add("c", 10)
element, err := p.RollDice()

Reset removes all elements and resets picker variables.

p.Reset()

About

Picker is a package that randomly picks an element based on its weight

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages