Skip to content

Instantly share code, notes, and snippets.

function Random(seed) {
this.seed = Math.random() * Math.pow(2,31);
this.a = 1103515245;
this.c = 12345;
this.m = Math.pow(2, 31);
}
Random.prototype.next = function() {
this.seed = (this.a * this.seed + this.c) % this.m;
return this.seed;