I'm creating a simple top down RTS game. I plan on it "randomly" generating maps on the fly when I need to. I plan on it all working in 'passes':

  1. Fill the terrain in with all grass
  2. Go back and add some random spurts of gravel
  3. Round out the gravel
  4. Draw Mountain Landscape on second layer
  5. Round out mountains
  6. etc. etc.

Now, take a look at this picture below:

enter image description here

I hand created this using my map editor but I plan on this basically being the result after hopefully pass/step 3.

How should I go about deciding when and were to place my gravel so that it is at least irregularly shaped and sporadic enough to look natural?

Thanks if you can! Any and all help is appreciated!

As a side note:

Each pass is basically me iterating through all of my tiles (The map is divided into 40x40 tiles) similar to this:

for (int x = 0; x <= GRIDMAX - 1; x++) {
    for (int y = 0; y <= GRIDMAX - 1; y++) {
        //Terrain(x, y, 0) = SomethingHere;

3 Answers 3


You can play around with Perlin Noise (see my StackOverflow answer for an implementation), to generate a height map. From the height map, you can map certain height ranges to different tiles. Something like:

  • Top 20% Snow
  • Next 20% Gravel
  • Next 40% Grass
  • Last 20% Water

You will have to play with the Perlin Noise generator values to get a terrain that can be generated and look nice.


As the others have said, perlin noise should be a good source of data for deciding where to place different types of tiles. I'd like to complement that idea and link two additional resources that should be helpful with with the third step in your checklist - rounding the corners.

This is a process called auto-tiling and it's not all that difficult to implement. There are many different ways to do it, but most of them rely on calculating adjacency information for each tile in order to decide which graphic should be drawn in that location.

A very elegant way to solve this problem is to assign a unique flag value to each adjacent tile direction, and lay out your spritehseet such that the value you get by adding together all the adjacent flags of a tile will correspond to the correct position of the tile in the spritesheet. Read this article for a very clear description of the technique.

And here's another resource which describes another variation of the technique.

  • \$\begingroup\$ Hey, just to let you know, your answer was extremely helpful as far as rounding the corners. Thanks a ton :) It actually all now works (even the rounding corners)! \$\endgroup\$
    – Freesnöw
    Commented Mar 7, 2012 at 11:01

Essentially you can use Perlin Noise generation to generate your maps. You would sample the height map generated and assign gravel blocks to parts of the map that have above a certain height.

Here is an excellent reference post on how to go about implementing such a system and different types of terrain that you could generate.

The examples have a lot more steps than you would need, but the concept is the same.

More on Minecraft-type world gen


enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .