Last active
August 8, 2017 00:20
-
-
Save Claire/0008ef9625a5a9fc64e870c7e0ff6483 to your computer and use it in GitHub Desktop.
example random with seed in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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