std/mersenne

  Source   Edit

The Mersenne Twister random number generator.

Note: The procs in this module work at compile-time.

Example:

import std/mersenne
var rand = newMersenneTwister(uint32.high)  ## must be "var"
doAssert rand.getNum() != rand.getNum()  ## pseudorandom number

See also

Types

MersenneTwister = object
  mt: array[0 .. 623, uint32]
  index: int
The Mersenne Twister.   Source   Edit

Procs

proc newMersenneTwister(seed: uint32): MersenneTwister {....raises: [], tags: [].}
Creates a new MersenneTwister with seed seed.   Source   Edit
proc getNum(m: var MersenneTwister): uint32 {....raises: [], tags: [].}
Returns the next pseudorandom uint32.   Source   Edit