Looking for an algorithm to generate a flat 2D map
I'm not sure if "traditional" random noise-based height-map generation is what I need, because what I want to end up with is a very simple map consisting of two types of region.
The end result I want is some very simple geometry dividing 'land' areas from 'sea' areas, and determini开发者_Python百科ng if a point is wet or dry.
Ideally it should all be procedural, rather than based off pre-rendered height-maps, as I want the map to be randomly generated and somewhat parameterised.
Closest examples I can think of are the map-generators in the SimCity and Civilisation series, but simplified right down to 2D with a feel of Defcon.
Something like: Start at any point. Declare it height 0 (beach). Recursively visit each adjacent point North, East, South, and West ala a flood fill passing the current node's height. Add or subtract some parameterized, random value (say -2 to 2). Clamp the values at min and max overall values (say -5 and 20). Recurse through your map size ignoring previously visited nodes. You now have a fairly contiguous 2D height map. Negative height is wet. You can play with how much the height changes per node and the min/max overall values to get more or less land - ocean's and continents vs archipelago's, etc.
精彩评论