PyTerrain
PyTerrain is an terrain generator created by StripedChessie and me, which uses fractional Brownian motion based on simplex noise to generate fantasy world maps. An example map generated by PyTerrain is shown below.
As indicated by the name, the program is written in Python, and makes use of two libraries: pillow, and noise. Pillow is a fork of the Python Imaging Library (PIL) and is used for creating the actual image output. Noise is th elibrary we used for generating fBm. It contains methods for generating both original Perlin and Simplex noise, and fBm based on both.
The generator works by running taking the fBm height at each point on the image, and determining based on the height what color that pixel should be. A sea level is selected, and any area lower than that is colored for water, and any area above that is colored for land. There is also an offset height for coast, where water within the “coast” height difference of the sea level is colored lighter. The same is applied to the land to give the shore a lighter color. Areas marked mountainous are determined based on an absolute height value from the lowest possible height.
The original program was written by StripedChessie. In the original version the values for pretty much everything except the width, height, and offset of the resulting image were hard coded.
I included python’s builtin argparse library, and used it to make basically everything about the output configurable. Everything from the choice of colors to the number of octaves of fBm to use can now be set on the command line. I also added an option to output the raw heightmap rather than a colorized map.
For future improvements, we have discussed adding another overlayed Simplex noise function controlling the multiplier applied to lower octaves of the fBm. By increasing or decreasing the multipliers on lower octaves of the fBm, you control the smoothness of the resulting terrain. This would cause some areas to have rougher terrain, which could be use as part of the determination of what terrain color to use for that area, i.e. rocky areas could have a different color from smooth areas.
A much more complicated option is to add water in random places above sea level, and simulate the flow of that water over the terrain. This would take a lot more work to implement both because of the need to simulate fluid motion, but also because a simplex base fBm is fundamentally smooth, so it is likely that the water flow would be highly prone to spreading out an pooling rather than making smaller rivers and streams. To fix this, giving the water some amount of erosion effect might be necessary.
Other terrain features, with different colors could be added with some amount of partially randomized condition for their appearing, such as forested areas, or grassy vs desert plains. The smooth nature of the fBm we’re using also means that the basic map will never contain any cliffs interesting features of that nature. We’ve also discussed (without any particularly serious plans of implementing) running some amount of weather simulation over the map for some number of cycles, in order to generate a climate (as the simulation stabilizes over time). Combining this with simulated erosion could make for more realistic maps.