Monday, January 5, 2015

Moisture Simulation

Recap

I'm developing a random RPG campaign map generator, and have the following pieces in place:


Precipitation

The next piece of the puzzle is generating a moisture map that represents the average precipitation at each point on the world.  A combination of the temperature, moisture, and elevation will ultimately determine which hex terrain is chosen for a particular point.

Algorithm

My first pass at modeling precipitation can be summed up as:
  1. Create several randomized wind bands.  Winds will blow left to right across the map, but these randomized zones will provide some cross-currents.
  2. Complete a number of cycles of simulated air circulation.  The number of cycles is set to the width of the map.  With the maps I am currently working with, this means 768 cycles of simulated air circulation.  For each cycle:
    1. For every water point on the map, add a small amount of moisture to that point.
    2. Use the wind bands to "blow" the air map one space.
    3. Subtract a small amount of moisture from each point, based on the elevation at that point.  This step is intended to simulate the deserts that can form next to mountain ranges.
Results

The example below shows a simulated moisture map after 768 cycles of simulated air circulation.  I'm generally pleased with the result.  The mountains in the upper left continent are producing a large desert region, there are numerous areas of moderate moisture which will map to plains, and much of the map has high moisture, which will lead to forests and jungles, depending on the temperate in the area.

The only problem with the approach is the processing time involved.  It takes about 15 seconds of processing to complete the 768 cycles of simulated air circulation.  I think I can create a simpler approach that will be orders of magnitude faster, and still produce acceptable results.

Elevation Map
Moisture Map after 768 cycles

No comments:

Post a Comment