pcgbasic
Permuted Congruential Generator (PCG) Random Number Generation (RNG) for Nim.
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Passing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install pcgbasic
choosenim install pcgbasic
git clone https://github.com/rockcavera/pcgbasic
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| pcgbasic | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/rockcavera/pcgbasic |
|---|---|
| Homepage | https://github.com/rockcavera/pcgbasic |
| Documentation | View Documentation |
| Registry Source | nimble_official |
README
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