You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
473 B

  1. 'use strict';
  2. // Found this seed-based random generator somewhere
  3. // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
  4. var seed = 1;
  5. /**
  6. * return a random number based on a seed
  7. * @param seed
  8. * @returns {number}
  9. */
  10. function getNextValue() {
  11. seed = (seed * 9301 + 49297) % 233280;
  12. return seed/(233280.0);
  13. }
  14. function setSeed(_seed_) {
  15. seed = _seed_;
  16. }
  17. module.exports = {
  18. nextValue: getNextValue,
  19. seed: setSeed
  20. };