Skip to content

Permuted Congruential Generator (PCG) Random Number Generation (RNG) for Nim.

License

Notifications You must be signed in to change notification settings

rockcavera/pcgbasic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Permuted Congruential Generator (PCG) Random Number Generation (RNG) for Nim.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages