This is useful if you need a reproducable/seeded psuedo-random number generator in JavaScript.

Rand = (function() {
  var _seed = Math.floor(Math.random() * 1000000000000);
  var _cur = _seed;

  var resetSeed = function() {
    _cur = _seed;
  };

  var setSeed = function(number) {
    _seed = parseInt(number);
    _cur = _seed;
  };

  var getRandom = function(seed) {
    var x = Math.sin(seed ? seed : _cur++) * 100000000;
    return x - Math.floor(x);
  };

  return {
    seed: setSeed,
    random: getRandom,
    reset: resetSeed
  };
})();