Terrain generator algorithm
![terrain generator algorithm terrain generator algorithm](https://i1.rgstatic.net/publication/260366081_A_survey_of_procedural_terrain_generation_techniques_using_evolutionary_algorithms/links/552f2d800cf22d437170db35/largepreview.png)
The tectonic forces that gave rise to this geography were a little drunk at the time. Now there is a tradeoff here! If you initialize too many points in your gird, you end up with maps which don't have much coherent structure: Modified algorithm lets you initialize a grid, and works its way in through each of the regions, which all share borders and can see into their neighbors when appropriate. The standard algorithm lets you initialize 4 corners, then works its way inward. Whereas in the original algorithm you just initialize the four corners, either all to the same value (boring) or to some random value (a little less boring), I modified it to allow you to initialize an arbitrary sized grid. To get around this, I modified the initialization step a bit. This really limits the diversity of maps you can generate, and just won't do. Especially when you are transforming it to a 2D map anyway, you will lost most of the fine details later iterations created, and you just get a HUGE boring map. There is room for finer and finer details, but ultimately your map is limited to the features the first few steps came up with. In game, then, you will have to walk over a LOT of tiles to cover much distance, which kind of sucks.
![terrain generator algorithm terrain generator algorithm](https://farm5.static.flickr.com/4069/4462870383_46e86b155c_o.jpg)
Thus, whereas a grid cell in the top image may cover 10 square miles, a grid cell in the bottom image may only by 10 feet by 10 feet. You don't really get any new features, you just get refinements on features already there. To get an idea of what I mean, consider a few iterations of the diamond square algorithm from the gameprogrammer article: it just builds the same world at a finer and finer scale. I don't like the idea of going from n=9 (513 cells) to n=10 (1025 cells) with no middle ground! I didn't like it one bit.Īlso, and perhaps even worse, while setting n to a larger number creates a larger map, it's not really that it builds a larger world. First and foremost, it can only build maps which have dimenions 2^n+1. It does, however, have some unfortunate limitations.
![terrain generator algorithm terrain generator algorithm](https://cdn1.epicgames.com/ue/product/Screenshot/16-1920x1080-2135113217ade22cafff150dea32ebd1.jpg)
It breaks the algorithm down into tiny bitsized steps, and is awesome! My guiding light in this part was an article from on fractal terrain generation. I liked the look of Diamond-Square a little more, and it seemed easier to implement than Perlin Noise anyway. In this image, 0.0 is black and 1.0 is white.Okay, time to talk about the random terrain generation algorithm, so that you too can have some cool maps!Ī little research brought me to two common random terrain algorithms, Perlin Noise and Diamond-Square. We assign each location on the map a number from 0.0 to 1.0. This is what the noise function looks like: Noise #Ī common way to generate 2D maps is to use a bandwidth-limited noise function, such as Simplex or Perlin noise, as a building block.
![terrain generator algorithm terrain generator algorithm](https://d3i71xaburhd42.cloudfront.net/cba7d57b71ad11dfe841c9d3091a57495222d5e3/3-Figure1-1.png)
Terrain generator algorithm how to#
I’m only going to explain how to fill an array with height and biome map data. I’m not going to explain how to draw these maps that’s going to depend on your language, graphics library, platform, etc. The simpler technique can make maps like this in under 50 lines of code: I started with something much simpler, which I’ll describe here. One of the more popular pages on my site is about polygonal map generation.