Skip to content

Instantly share code, notes, and snippets.

@orodio
orodio / prng.js
Created March 3, 2020 19:08 — forked from blixt/prng.js
A very simple, seedable JavaScript PRNG.
/**
* Creates a pseudo-random value generator. The seed must be an integer.
*
* Uses an optimized version of the Park-Miller PRNG.
* http://www.firstpr.com.au/dsp/rand31/
*/
function Random(seed) {
this._seed = seed % 2147483647;
if (this._seed <= 0) this._seed += 2147483646;
}