pcgbasic
所属分类:数学计算
开发工具:Nim
文件大小:0KB
下载次数:0
上传日期:2023-01-14 00:18:46
上 传 者:
sh-1993
说明: Nim的置换同余发生器(PCG)随机数生成(RNG)。
(Permuted Congruential Generator (PCG) Random Number Generation (RNG) for Nim.)
文件列表:
LICENSE.md (1067, 2023-01-13)
examples/ (0, 2023-01-13)
examples/config.nims (36, 2023-01-13)
examples/pcg32demo.nim (2420, 2023-01-13)
examples/pcg32globaldemo.nim (2364, 2023-01-13)
examples/pcg32x2demo.nim (4194, 2023-01-13)
pcgbasic.nimble (248, 2023-01-13)
src/ (0, 2023-01-13)
src/pcgbasic.nim (2885, 2023-01-13)
src/pcgbasic/ (0, 2023-01-13)
src/pcgbasic/utils.nim (303, 2023-01-13)
tests/ (0, 2023-01-13)
tests/config.nims (36, 2023-01-13)
tests/test1.nim (816, 2023-01-13)
# 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
```nim
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
```
近期下载者:
相关文件:
收藏者: