Seedable Random number generator in JavaScript [du

2020-03-15 01:31发布

I'm looking for a random number generator in JavaScript which I can initialize with a certain seed and gives a deterministic result (according to that seed). It should be capable of providing random integers within a certain range, however I can work with a random number generator that spits doubles, too (just like Math.random()).

Basically I'm looking for an equivalent to java.util.Random as known in the Java World for JavaScript.

Is there something like this already built into JavaScript? Is there some (maybe HTML5 related API) which specifies such a thing? Is there a library providing such a random number generator?

I'm implementing a genetic algorithm in JavaScript and I need to be able to harvest the same results for the same inputs (including seed) for research.

1条回答
Lonely孤独者°
2楼-- · 2020-03-15 01:41

This might help you, I just found it on the internet. It's apparently a replacement for Math.random()

http://davidbau.com/encode/seedrandom.js

查看更多
登录 后发表回答