Last active
August 29, 2015 14:20
-
-
Save thejustinwalsh/1f60f1c1f1ff19af03a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class util.Random | |
{ | |
public static function get instance():Random { return _instance; } | |
public function Random(seed:Number) | |
{ | |
r = seed; | |
if (!_instance) _instance = this; | |
} | |
public function next():Number | |
{ | |
r = (r*9301+49297) % 233280; | |
return r / 233280.0; | |
} | |
public function range(min:Number, max:Number):Number | |
{ | |
return Math.floor(next() * (max - min +1 ) + min); | |
} | |
private var r:Number; | |
private static var _instance:util.Random; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment