mirror of
https://github.com/rockcavera/pcgbasic
synced 2026-01-15 10:41:31 +00:00
No description
| examples | ||
| src | ||
| tests | ||
| LICENSE.md | ||
| pcgbasic.nimble | ||
| README.md | ||
pcgbasic
Permuted Congruential Generator (PCG) Random Number Generation (RNG) for Nim.
This implementation Nim was based on the minimal implementation written in C.
More information: http://www.pcg-random.org/
C implementation: https://github.com/imneme/pcg-c-basic
Install
Run the Nimble install command
nimble install pcgbasic
Basic usage
import pcgbasic, pcgbasic/utils
let seedseq = genSeeds()
var rng: Pcg32Random
# Start an rng
pcg32SRandomR(rng, seedseq.seed, seedseq.seq)
# Return a unit32
echo pcg32RandomR(rng)
# Pick a number between 0 and 99
echo pcg32BoundedRandR(rng, 100'u32)
# Roll a six-sided dice
echo pcg32BoundedRandR(rng, 6'u32) + 1