It’s quite easy to do this using seedrandom. You simply load the library in your index.html:
<script src="//cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.5/seedrandom.min.js"></script>
Then early in the main script call it with your string as the seed:
Math.seedrandom("your seed string");
This will replace Math.random()
with a deterministically seeded version and you will get the same results each time.
One other option is to seed ROT.RNG.setSeed()
and/or use a cloned RNG with ROT.RNG.clone()
which may give you more control in specific circumstances.