Some semi-random thoughts on terrain generation
I've added a second implementation of the generator, GrownProt, which is exactly the same, but the code is probably easier to understand and it's really easy to play with it, chain the generators in a different way and see what that creates. The downside is that this easier code is less performant (I measured some 15 % loss, with a crude timer), so once I find a good chain for the int generators, I'll rewrite it back into the original version. I might keep the prototyping code in, if there's an interest.

For those of you who'd like to poke around: Probably the biggest surprise is how the generator achieves such random yet compact shapes. This comes mostly from one single thing - the Zoom class. It zooms the generated array by a factor of 2, but instead of using nearest-neighbor, or some form of bilinear interpolation, it uses a simple "random neighbor" decision. So in order to generate an N * N square of values, it first lets the underlying generator generate (N / 2 + 2) * (N / 2 + 2) square of values, and then for each square of 3 * 3 neighbors, sets the corners to the original values, the 4 values along the edges to a random one of the adjacent corner values, and the center value to a random one of the four corner values. That's it, that's the complete magic.
The rest of the methods just provide some smart biome selection, first deciding about where to put groups such as oceans, hot biomes, temperate biomes, cold biomes and mountainous biomes, zooming a few times to randomize the shapes, then choosing random biomes for each of the biome groups, again zooming a few times. By now the biomes are mostly formed, so the final steps are to do an edge-detection on the ocean-side, this creates beaches; zooming for the final time makes the beaches somewhat larger.
Reply
Thanks given by:


Messages In This Thread
RE: Some semi-random thoughts on terrain generation - by xoft - 10-31-2014, 01:36 AM



Users browsing this thread: 10 Guest(s)