• Advertisement
Sign in to follow this  

Biome based map generation?

This topic is 572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone!

 

I'm working on an RTS where I want to generate maps. The concept of biomes are very important as some buildings can only exist in some biomes etc. What are some of my options here?

 

I've found tons of articles, tutorials, samples and libraries, but almost all of them use a height map to determine biome. This gives reasonably realistic results etc, but boring since certain biome types will always be next to eachother. I want a technique that can result in a mountain with a lake to the north, a forrest to the west and a dessert to the right.

 

My current generator uses a fixed size tile map, randomly places some biome "centers" on it, then does an incremental flood fill to spread these biomes. The results are rather nice, but it's extremely slow and does not support expansion.

 

How does games like Minecraft do this? What are some other options?

 

* It must support populating a presized tilemap at the very least, but ability to seamlessly expand is a big plus

* Control over biome density is a huge plus. Some are supposed to be rare, others are supposed to be common, all players need reasonable access to some etc.

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

The advantage of using a heightmap/temp/moisture/etc method is that you won't end up with a polar region at the equator or a polar region and a dessert region directly next to each other.

 

I want a technique that can result in a mountain with a lake to the north, a forest to the west and a dessert to the right.

 

 

Lakes/rivers... pretty much any water related feature is generally (I think) not considered a biome and added "Ontop" of any biome already in place. I am going to assume you mean to say that mountains, forests and desserts can be adjacent rather than specifically in a north/west/east orientation... do you want to enable polar regions to be next to desserts? or rainforests at the poles? 

 

 

For my implementation I am using the Heightmap method for placing a base biome,but then I plan on giving each base biome a random chance to morph into a specific sub biome of that base type... for example, the height map method may produce a region that is polar... I will then give it say a 20% chance of becoming one of either a Frozen Forest, Ice caves,hot springs, yeti country, or... I don't know... blue dragon graveyard or something. This way any area that implies it should be cold will be on a location on the planet where it makes sense to be cold but there will still be variety.

Share this post


Link to post
Share on other sites
My go-to trick with procedural landscapes has always been (and, at this rate, probably always will be!) a derivative of a noise function. Simplex noise is the most useful and modern variant I'm aware of personally.

Share this post


Link to post
Share on other sites

I've never used this technique for games, but I think it should work for biome generation.

 

If you have multiple layers of low res noise (such as perlin), and combine them to create a probability vector, describing what biome is the dominant for an area.

 

The most basic example for this, is just to associate each layer of noise with a certain biome type, such that the areas where the tropical noise layer has the highest value, the biome will be tropical. 

 

To prevent a snow biome spawning next to a dessert, you can achieve a more sophisticated result by having the noise layers represent environmental properties, such that the biomes can be derived from these properties.

 

Example time:

 

noise layer #1 "Temperature"

noise layer #2 "Humidity"

 

Derived biomes:

Temp < 33% and Humidity < 50% => Cold rocky biome

Temp < 33% and Humidity > 50% => Ice and frozen lakes

33% < Temp < 66% and Humidity < 50% => Grassland
33% < Temp < 66% and Humidity > 50% => Forest or swamp

Temp > 66% and Humidity < 50% => Dessert

Temp > 66% and Humidity > 50% => Tropical rainforest
 

Share this post


Link to post
Share on other sites

My go-to trick with procedural landscapes has always been (and, at this rate, probably always will be!) a derivative of a noise function. Simplex noise is the most useful and modern variant I'm aware of personally.

 
Do you have an article or something about this, preferebly not too heavy on math? I've studied way less math than I should have back in college, and at this point I don't have the time.. I'm trying to wrap my head around what this means. If I had a 2D noise function used to generate a height map, would the derivate of that be something like the tangent and/or normal? Some form of vector at least? Or is it just a scarlar representing some form of slope?
 
 

The advantage of using a heightmap/temp/moisture/etc method is that you won't end up with a polar region at the equator or a polar region and a dessert region directly next to each other.

 
I don't care at all about realism, I care much much more about balance. All players will effectively need access to their own instance of biome A and B, while they may need to fight for that small and rare instance of biome C. The biome instances will be really small, something like 50x50-300x300 meters or something. Minecraft is actually a really good example of what I want, even though it's a completely different game.
 

I've never used this technique for games, but I think it should work for biome generation.


This is an interesting technique.

Share this post


Link to post
Share on other sites
Sorry, I didn't mean "derivative" in the calculus sense. I meant literally like "something modified from or inspired by."

If balance rules are substantial parts of your design, you might look at combining Lindenmayer systems with a noise function. Edited by ApochPiQ
I cunnot spahl

Share this post


Link to post
Share on other sites

So I feel like there's some basic fundamental technique I'm missing here.

 

Whenever I think of noise, I think of a function that takes X and Y and returns a value in a defined interval, say 0..1. This can easily be used to create a height map etc. If I were to use noise to select biomes, I would chop the resulting interval into sub-intervals and assign a biome to each sub-interval. Very simple and straight forward. By assigning biomes different sized sub-intervals, I could control how common/likely they are to appear etc. But I can't seem to figue out how to use this technique to get rid of the whole biome instances are always fully contained in the next or previous biome type.

 

Is there some other way to interpret/use noise that I'm overlooking?

 

I wonder if I can come up with a function that given an X and Y pair would return the closest point matching some criteria.. That would be great, because then I could just sample a noise map at the point and use that value.

Share this post


Link to post
Share on other sites

Noise is an approach you use when you want broadly continuous values. What you probably want in this case are discrete values, one value for each potential biome. For that purpose, you probably want a simple hash function where the input is the map coordinates - rounded to the nearest X, where X is the width and height of the biome - and the output is an integer, which you can treat as a random number, used to select your biome from a list (perhaps weighted).
 
e.g.

int hash2D(int x, int y)
{
    // combine x and y into a single value
    int64 z = (x * 93851) + y; // 93851 is a prime, chosen to be larger than any value of y

    // now use a hash function designed for integers, picking off only the bottom 32 bits
    int result = (int)z*2654435761 & 0xffffffff;

    return result;
}

 
(I've not verified the above code, but hopefully you get the point).

Share this post


Link to post
Share on other sites

Noise is an approach you use when you want broadly continuous values. What you probably want in this case are discrete values, one value for each potential biome. For that purpose, you probably want a simple hash function where the input is the map coordinates - rounded to the nearest X, where X is the width and height of the biome - and the output is an integer, which you can treat as a random number, used to select your biome from a list (perhaps weighted).
 
e.g.

int hash2D(int x, int y)
{
    // combine x and y into a single value
    int64 z = (x * 93851) + y; // 93851 is a prime, chosen to be larger than any value of y

    // now use a hash function designed for integers, picking off only the bottom 32 bits
    int result = (int)z*2654435761 & 0xffffffff;

    return result;
}

 
(I've not verified the above code, but hopefully you get the point).

 

Sure, but wouldn't that result in rectangular or at least very regularly shaped biome patches? I want something that's irregular..

 

If you want, take a look at this:

 

http://dvdmandt.net/grand/rev39/terrain_provinces.png (warning, 7.2mb image)

 

That's from an experiment I made earlier where I wanted to dynamically create maps for a game similar to Europa Universalis. The terrain in that example is based on a height map with intervals assigned to different biome types, so ignore that and focus on the regions. I love their shapes etc. The technique used in that picture is very similar to what I'm doing in my current map gen, ie drop lots of points on a grid and then use incremental flood fill until the whole grid is covered. The results are great, but it's slow as hell and not expandable after initial generation which is why I'm looking for other solutions.

Share this post


Link to post
Share on other sites

Okay, so 'how does Minecraft do it' quickly becomes less relevant when you want irregular shapes. It would be helpful to have all your requirements listed in one place, such as the need for non-rectangular areas, and a clear definition for what "not expandable after initial generation" means - do you need a potentially infinite map? What exactly gets expanded?

 

Generating irregularly shaped regions is covered in detail in a bunch of places. I like this source - http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

With that method, note that the regions at the edges may change in shape if you expand the map later. But none of this has anything to do with biomes.

 

Picking a biome for each region can again be as easy or hard as you like. You could plug the centroid point of the region into a hash function, as mentioned above.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement