17 lines
343 B
JavaScript
17 lines
343 B
JavaScript
export class SeededRandom {
|
|
constructor(seed) {
|
|
this.seed = seed;
|
|
}
|
|
|
|
// Generates a random number
|
|
next() {
|
|
this.seed = (this.seed * 9301 + 49297) % 233280;
|
|
return this.seed / 233280;
|
|
}
|
|
|
|
// Generates a random integer within a range
|
|
nextInt(min, max) {
|
|
return Math.floor(this.next() * (max - min + 1)) + min;
|
|
}
|
|
}
|