Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Deterministic Generation from Provided Seed

A topic by MishaBoar created Jan 04, 2022 Views: 133 Replies: 2
Viewing posts 1 to 3

Hello there!

Would it be possible with this boilerplate code to generate levels deterministically? I have a 65 character string I need to use to generate levels in a deterministic way - how difficult would it be?

Thanks!

Developer

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.

Fantastic @chr15m! Thanks!