How to create reproducible probability in map generation?

Posted by nickbadal on Game Development See other posts from Game Development or by nickbadal
Published on 2012-06-24T19:45:58Z Indexed on 2012/06/24 21:24 UTC
Read the original article Hit count: 226

So for my game, I'm using perlin noise to generate regions of my map (water/land, forest/grass) but I'd also like to create some probability based generation too. For instance:

if(nextInt(10) > 2 && tile.adjacentTo(Type.WATER))
    tile.setType(Type.SAND);

This works fine, and is even reproduceable (based on a common seed) if the nextInt() calls are always in the same order. The issue is that in my game, the world is generated on demand, based on the player's location. This means, that if I explore the map differently, and the chunks of the map are generated in a different order, the randomness is no longer consistent.

How can I get this sort of randomness to be consistent, independent of call order?

Thanks in advance :)

© Game Development or respective owner

Related posts about java

Related posts about procedural-generation