DicEx.RNG.Entropy (dicEx v0.1.0)

Copy Markdown View Source

Cryptographic high-entropy RNG. Every roll draws fresh entropy from the OS via :crypto.strong_rand_bytes/1 — the BEAM's CSPRNG, the same source used for secrets — so outcomes are effectively unpredictable.

strong_rand_bytes already mixes OS-level entropy (hardware timings, device jitter, RDRAND where available), which is strictly stronger than hand-mixing a clock value. Use this when you want honest, non-replayable rolls (a production demo, real games); use DicEx.RNG.Default when you need reproducibility via a fixed :seed (tests, replays, anti-cheat audits).

Rolls are stateless and uniform over 1..sides: rejection sampling removes the modulo bias a naive rem/2 would introduce on the small dice ranges.

DicEx.roll("2d20kh1", rng: DicEx.RNG.Entropy)