Set default seed value

This commit is contained in:
pyoor 2018-08-27 18:57:27 -04:00
parent 7252e9e2b5
commit 942d9d89ba

View file

@ -8,13 +8,9 @@ const {logger} = require('../logging')
class random { class random {
/** /**
* Must be called before any other methods can be called to initialize MersenneTwister * Must be called before any other methods can be called to initialize MersenneTwister
* @param {number|null|undefined} seed - Value to initialize MersenneTwister * @param {number} seed - Value to initialize MersenneTwister
*/ */
static init (seed) { static init (seed = new Date().getTime()) {
if (seed === null || seed === undefined) {
random.seed = new Date().getTime()
}
random.twister = new MersenneTwister() random.twister = new MersenneTwister()
random.twister.seed(random.seed) random.twister.seed(random.seed)
} }