Skip to content

Instantly share code, notes, and snippets.

@thejustinwalsh
Last active August 29, 2015 14:20
Show Gist options
  • Save thejustinwalsh/1f60f1c1f1ff19af03a1 to your computer and use it in GitHub Desktop.
Save thejustinwalsh/1f60f1c1f1ff19af03a1 to your computer and use it in GitHub Desktop.
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