An LCG random number generator that resembles the behavior of java.util.random
npm install @kobayami/random``sh`
npm install --save @kobayami/random
- Latest version: 1.0.0
- License: MIT
- Changes
An LCG random number generator that resembles the behavior of java.util.Random.randomInt()
This means the method of this generator will generate the same number sequence asjava.util.Random.nextInt() when both are initialized with the same seed.
The purpose of this package is to provide a random number generator
that can be initialized with seeds as to create reproducible random number sequences,
because JS Math.random() does not provide such a feature.
`ts
import { Random } from "@kobayami/random";
const WIDTH = 640;
const HEIGHT = 480;
const rand = new Random(1923968746);
function getRandomPixelPosition(): {x: number; y: number} {
return {
x: rand.randomInt(WIDTH),
y: rand.randomInt(HEIGHT)
}
}
``
- API Documentation
- Project Homepage
- Project on GitHub
- Issues