Created
October 3, 2012 23:13
-
-
Save ngryman/3830489 to your computer and use it in GitHub Desktop.
random seed
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
// the initial seed | |
Math.seed = 6; | |
// in order to work 'Math.seed' must NOT be undefined, | |
// so in any case, you HAVE to provide a Math.seed | |
Math.seededRandom = function(max, min) { | |
max = max || 1; | |
min = min || 0; | |
Math.seed = (Math.seed * 9301 + 49297) % 233280; | |
var rnd = Math.seed / 233280; | |
return min + rnd * (max - min); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From http://indiegamr.com/generate-repeatable-random-numbers-in-js/#comment-749