improcket/js/util.mjs
2018-03-02 01:32:18 +00:00

11 lines
236 B
JavaScript

export class SeededRandom {
constructor(seed) {
this.seed = seed % 2147483647;
}
next() {
this.seed = this.seed * 16807 % 2147483647;
if (this.seed <= 0) this.seed += 2147483646;
return (this.seed - 1) / 2147483646;
}
}