dice

package
v5.55.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 6 Imported by: 3 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dice contains common functions to generate random number. It also initialize math/rand with the time in seconds at launch time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Roll

func Roll(n int) int

Roll returns a non-negative number between 0 (inclusive) and n (exclusive).

func RollDeterministic

func RollDeterministic(n int, seed int64) int

Roll returns a non-negative number between 0 (inclusive) and n (exclusive).

func RollUint16

func RollUint16() uint16

RollUint16 returns a random uint16 value.

func RollUint64

func RollUint64() uint64

func RollWith added in v5.15.0

func RollWith(n int, random io.Reader) int

RollWith returns a non-negative number between 0 (inclusive) and n (exclusive). Use random as the random source, if read fails, it panics.

Types

type DeterministicDice

type DeterministicDice struct {
	*rand.Rand
}

func NewDeterministicDice

func NewDeterministicDice(seed int64) *DeterministicDice

func (*DeterministicDice) Roll

func (dd *DeterministicDice) Roll(n int) int

Jump to

Keyboard shortcuts

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