Advertisement

Random Map Generation

Started by October 03, 2003 11:21 AM
24 comments, last by psyjax 21 years, 4 months ago
Wow... those cloud generations look great!

Hmmm... I mean, they do produce rather nice map''s, I''ll give you that. But for the kind of game I''m building (an 2D isometric strategy/rpg) I think it may be a bit overkill.

Yet I do like it, and am interested in it, especially for later stages of development were height will be a bigger factor do define mountains, hills etc.

I especially like the idea that mountains, coastline, hills, lowlands, valleys etc. Are all logically placed by this algorithem. Do you have any suggested sources for someone beginning to look into this?

Thanks alot for your great suggestion.
Do a search in google for fractal cloud algorithms, should turn up a bunch of pages. It''s a rather simple algorithm that deals with subdividing a grid and tweaking the middle point a little. For instance... not sure how this is gonna turn out...

4...7
.....
.....
.....
7...9

These are your corner pixels. The number''s a color; let''s suppose from 0 to 9. Roughly, the algorithm takes all 4 "corner" pixels and averages them (4+6+7+7 / 4 = 6) then tweaks the result by a small value (say, ±2 here); the greater the value, the rougher the terrain will turn out. It then plots the middle pixel with that color.

4...7
.....
..6..
.....
7...9

The algorithm then recursively subdivides into smaller and smaller regions, always taking the 4 corner pixels in that region until it eventually fills the whole area. You can then do whatever you want with the result. I applied a palette over it to give it a landscape-like look, though you could just as easily make a heightfield out of it or use individual pixels to determine what tile to place on your map.

Here are a few links...

Java source to a fractal cloud applet
Not exactly it but close enough
Veritable storehouse of landscape-related stuff

Advertisement
I''m looking for information about a simmilar but different topic: How would I go about generating a ''base'' for a team game, where each base will consist of rooms, hallways, stairs, and lifts? Also, there are certain kinds of rooms that must exist {but in each base, the required rooms should be different sizes and arranged differently}, such as a spawn room, a store, a vehicle bay, a medical lab, etc. Not only do I need to generate the position and size of rooms and doors, but also the layout of everything in the room and make sure it meets certain requirements. For example, in the spawn room, there need to be at least 2 exits and 3-5 spawn tubes that can be clearly exited to either room exit {ie they won''t obstruct eachother so a person can get stuck in spawn}. In the store room, there are several types of terminals that can be both freestanding and against the wall and there should be a certain mixture of each type without blocking the required 2 exits (not all rooms require 2 exits, some must have only 1, some need several).

Any good hints on how I might go about this?
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
buy this book http://www.gamedev.net/columns/books/bookdetails.asp?productid=110

this has a chapter on ramdom map generation for 2d games..

Might help
Interested in being apart of a team of people that are developing a toolkit that can help anyone product an online game? Then click here http://tangle.thomson.id.au/
Look into random maze generation alroithms that allow the creation of rooms. With a bit of tweaking you could probably make sure it always generates at least one room with 3 exits, etc, then select a random room out of all the created ones to be the lab, an other for the spawn room, etc...

Hope that helps
For future reference, this isn''t really a Game AI problem, but rather a Game Design or even Game Programming problem. Please try to keep things on topic for this forum.

Thanks,

Timkin
Advertisement
Try this.

Been looking for this link for a long time, in fact. You should be able to find a couple of useful links and suggestions to generate a realistic landscape from that site. Very, very good tutorial, easily understandable.

Hope this helps

This thread should be moved to the graphics section, though. I agree this doesn''t really have much to do with AI
a note on the idea of overkill ...

IF you can get a good map like rune made, then you can turn it into a 2d iso map simply by averaging on a grid ... so if he has float heights, simple partition the heights into ranges ... etc ... the key it to get the interesting coastline, heightmap, and additions, IN ANY FORMAT - and then convert them to your games specific needs ... of course an algorithm custom taylored to a game engine is WAY easier to make spit out balanced maps (maps where multiple starting locations are at least partially "fair" ... Civ3 has a great generation algortihm ... but FAIR is never even attempted - if you save the game early, look at locations, and save later, almost all of the players rankings is based on quality of starting location (for computer players that is) ...

good luck
Re: Random maps for FPS, capture the flag bases.

This is a continuation of the "Ant" idea. A while back I used the ant system to generate Quake 3 maps.

Imagine a big grid of cubes instead of a grid of 2d tiles.

The maps were 3d; I made them by having the ant walk in 3 dimensions, or by making my grid of blocks from multiple 2d maps laid atop one another.

The only change is you need to handle the special case of an ant moving up, in which case you need to add a predesigned "stair" or "ramp" object.

You can also detect corners fairly easily and replaced them with beveled corners, which improves the appearance.

"Rooms" appear as an emergent behavior from when the ant crosses its own path multiple times in a certain area.

The ant also occasionally placed lights of random colors throughout the map, and weapons/objects.


It''s not a terribly sophisticated system, but I think you''ll be surprised by the results you can get.
I once tried something akin to TerranFury''s method (not to long ago, in fact, for a college project for a VB class. Long story short, our end of semester project is anything we wish. I''m making a dungeon crawler à-la rogue) and got sizeably impressive results. No screenie right now though, I ditched the code in favor of something "better" for what I was working on.

What I did initially was generate, say, 10-20 randomly sized rectangles across a 2D grid, not caring if they overlapped. Of course, I kept a tab on the location of each rectangle. This is because I then went from every rectangle and drew a path going to the next one in the list. For instance...

A...C
.....
..B..

Would have paths like...

A./-C
|.|..
\-B..

I was lazy and made the paths go straight down/up to the next rectangle, then straight right/left. Sometimes I''d invert the directions (horizontal then vertical).

I''d end up with a very nice map (especially after placing tiles on it) that wasn''t very realistic but had large rooms and passages. Though right now I''m using a simple linked-room style dungeon.

This topic is closed to new replies.

Advertisement