Documentation ¶
Overview ¶
Package rng implements a deterministic random number generator using cryptographic functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ForceSeed string
ForceSeed is a user-specified seed to use.
Functions ¶
func RandomSeed ¶
func RandomSeed() string
RandomSeed returns a random 16-character string with 80 bits of entropy.
Types ¶
type RNG ¶
type RNG struct { // Count is the number of bytes RNG has been advanced by. // // This number is not read by any RNG calculations, and is provided // for debugging only. Count uint64 // ReverseFloat generates float values in big-endian order to // maintain compatibility with a bug in previous versions of RNG. ReverseFloat bool // contains filtered or unexported fields }
RNG is a deterministic random number generator.
func (*RNG) CheapFloat ¶
CheapFloat returns a real number in [0, 1), advancing the random state by 1 byte.
func (*RNG) Clone ¶
Clone returns a full copy of this RNG.
It is not safe to use both RNG instances concurrently, but changes to one will not be reflected in the other.
func (*RNG) RangeFloat ¶
RangeFloat returns a real number in [min, max), advancing the random state by 4 bytes.
func (*RNG) RangeInt ¶
RangeInt returns an integer in [min, max), advancing the random state by a variable amount.
func (*RNG) RangeIntFloat ¶
RangeIntFloat returns an integer in [min, max), advancing the random state by a variable amount.
This function matches the behavior of RangeInt for integer min and max, and matches the behavior of JavaScript for non-integers.
Non-integer min causes the result to have min's fractional part.
A non-integer difference between min and max causes the last number to have a lower probability of occurring.