Solved

Terrain generating....help

Posted on 2000-04-24
9
920 Views
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....  
0
Comment
Question by:David MacDonald
9 Comments
 

Expert Comment

by:mlaughton
Comment Utility
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.
0
 
LVL 1

Author Comment

by:David MacDonald
Comment Utility
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....
0
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
This site has a few links which might be helpful:

http://members.tripod.com/gamecoder/terrain.htm
0
 
LVL 4

Expert Comment

by:jack_p50
Comment Utility
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:David MacDonald
Comment Utility
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.

pjknibbs:

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...:)
0
 

Accepted Solution

by:
mikefulton earned 50 total points
Comment Utility
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.
0
 
LVL 1

Author Comment

by:David MacDonald
Comment Utility
Adjusted points from 40 to 50
0
 
LVL 1

Author Comment

by:David MacDonald
Comment Utility
Answer accepted
0
 
LVL 1

Author Comment

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

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now