Module random

Nim's standard random number generator. Based on the xoroshiro128+ (xor/rotate/shift/rotate) library.

Do not use this module for cryptographic use!

Types

ui = uint64
  Source Edit

Procs

proc random(max: int): int {.
gcsafe, locks: 0, raises: [], tags: []
.}
Returns a random number in the range 0..max-1. The sequence of random number is always the same, unless randomize is called which initializes the random number generator with a "random" number, i.e. a tickcount.   Source Edit
proc random(max: float): float {.
gcsafe, locks: 0, raises: [], tags: []
.}
Returns a random number in the range 0..<max. The sequence of random number is always the same, unless randomize is called which initializes the random number generator with a "random" number, i.e. a tickcount.   Source Edit
proc random[T](x: Slice[T]): T
For a slice a .. b returns a value in the range a .. b-1.   Source Edit
proc random[T](a: openArray[T]): T
returns a random element from the openarray a.   Source Edit
proc randomize(seed: int) {.
gcsafe, locks: 0, raises: [], tags: []
.}
Initializes the random number generator with a specific seed.   Source Edit
proc shuffle[T](x: var seq[T])
  Source Edit
proc randomize() {.
gcsafe, locks: 0, raises: [], tags: [TimeEffect]
.}
Initializes the random number generator with a "random" number, i.e. a tickcount. Note: Does not work for NimScript.   Source Edit