How to create reproducible probability in map generation?
- by nickbadal
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 :)