Skip to content

Instantly share code, notes, and snippets.

@Claire
Last active August 8, 2017 00:20
Show Gist options
  • Save Claire/0008ef9625a5a9fc64e870c7e0ff6483 to your computer and use it in GitHub Desktop.
Save Claire/0008ef9625a5a9fc64e870c7e0ff6483 to your computer and use it in GitHub Desktop.
example random with seed in javascript
function Rando(inSeed) {
origSeed = inSeed || Date.now();
result = {
// the initial seed
origseed : origSeed,
seed : origSeed,
seededRandom : function(max, min) {
max = max || 1;
min = min || 0;
this.seed = (this.seed * 9301 + 49297) % 233280;
var rnd = this.seed / 233280;
return min + rnd * (max - min);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment