[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Terrain generating....help

Posted on 2000-04-24
Medium Priority
Last Modified: 2013-11-16
Could someone point me the right direction in the way to make a algorythm to generate a random map (with % of mountain, lakes, forest, etc.), I don't use MFC, but the game is starting to implement Windows programming stuff, so if anyone has links to tutorials, I would appreciate...

I had the idea to use fractal generating for the map, but then I can't specify the % of terrain type wanted....  
Question by:David MacDonald
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 2745777
If you are trying to do this on-the-fly during your program, this tip won't help.  But if you'd like to generate 3D terrain before the fact, I'd really suggest checking out Bryce (formerly produced by MetaCreations, now owned by Corel).  9 months ago I wrote a simple program to generate terrain and just 2 weeks ago I found that Bryce does everything I originally wanted and oh so much more.

There are also a lot of rendering features such as textures and effects, but the actual terrain modeling tool is what I use it for.  There are several pre-packaged filters for different effects (water, lava, fractals, mountains, crystals, to name a few).

The real-time editing is done through a 2D bitmap & paintbrush, while the 3D preview version is shown using some kind of volume-rendering.  When you achieve the terrain you're going for, you accept the preview and it is tesselated into 3D polygons for you.

So far I haven't found any controls over the polygons that are created (which is necessary when concerned with 3D game performance) so another 3rd-party application might be needed for optimizations (Blender?, 3D Studio Max?).

Anyway, I hope this helps you out.

Author Comment

by:David MacDonald
ID: 2748363
Thanks, your tip gave me an idea about another concern we had about the game, but the maps have to be generated during the program. Basically what we are doing is kind of an old type rpg sim game. The user will be asked what kind of terrain he wants, so the maps have to be generated on demand....
LVL 12

Expert Comment

ID: 2756300
This site has a few links which might be helpful:

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.


Expert Comment

ID: 2767241
why don't you like fractals?
you may generate fractal different elevation (height) map; so low is lakes, high is mountains, and then randomly create some forests

Author Comment

by:David MacDonald
ID: 2769278
It's not really that I don't like fractals (I love em...hehe)... but I can't think of a way to generate a fractal with a % of land, mountain, sea..etc.


I've looked at the site....pretty nice... it gave us an idea about another game we hope to make soon.... but the terrain we want for the present game is a 2D map..... more like a gameboard...
but thanks a lot...this link as been bookmarked...:)

Accepted Solution

mikefulton earned 200 total points
ID: 2927433
You can use fractals and still exert some control over what percentage of the map is water, what percentage is mountain, what percentage is plains, etc.

To explain how, let me first briefly outline how a fractal map would be generated in the first place.  You probably already know this, but just in case...

The usual procedure is to assign random (or pseudo-random) numbers to the corners of the map.  This gives you a single large rectangle with values for each corner.  Now you subdivide that rectangle into 4 quadrants.  

To get the values for the new points of the 4 quadrants, you interpolate the corner values of the rectangle you just subdivided, then another random value is added to the result.

The magnitude of the random value that gets added is weighted by how many steps of subdivision you have done so far, so that in the early stages of creating the map, the random numbers may be large, indicating large changes in terrain.  In later stages of map creation, the random numbers are smaller, which would indicate more gradual changes in terrain.

This is one place where you can control your resulting map.  By changing the weighting of the random value according to how many subdivision steps you've done so far, you will get different types of landscape.

The subdivision process is repeated until you get down to the point where you can't subdivide any more because you can't split a pixel in half.

Now we get to how to control the map output.  If you want to specify certain percentages of certain terrain types, then instead of simply assigning random numbers to the map, select values that indicate the desired type of terrain.  

Instead of simply assigning the original 4 corners, you'll start out by subdividing the map into smaller sections right from the beginning.  For example, if you have a 256x256 map, then breaking it down into 16x16 squares will give you 256 points to set.  By selecting 256 values that are weighted towards your desired percentages of each terrain type, this should give you the control you want.

It may also be that doing an initial 8x8 grid with 64 seed values gives you fine enough control.  You'll have to experiment a bit.

By the way, when you assign your initial 256 values (or 64 values, or whatever) you might want to set two adjacent points to the same value.  This would give you a better guarantee that a particular area will show the desired terrain type.  If you set just one point, then the surrounding points could still be drastically different, and you might not get the desired result.  It's something you'd have to play around with a bit.

Another thing to consider is that you might want to specify terrain using two values instead of one.  The most simple fractal landscape generation uses a single value and presumes that everything below a certain threshold is in water, and everything above another threshold is snow-capped mountain.

There's no reason you *have* to do it that way.  You could use two values.  One would indicate the basic terrain type, such as water, grassland, forest, desert.  A second value would indicate elevation relative to the terrain type.  The combination of the two values would allow you to do things that a single value wouldn't allow, such as having a lake in a mountain valley.

Well, I hope this helps.

Author Comment

by:David MacDonald
ID: 2929219
Adjusted points from 40 to 50

Author Comment

by:David MacDonald
ID: 2929220
Answer accepted

Author Comment

by:David MacDonald
ID: 2929221
Altough I do not understand all of it, I think I grasped much of the concept....

I'll try this one.... thanks mike!!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question