Advertisement

Random Maps

Started by February 05, 2000 07:48 AM
3 comments, last by thekid 24 years, 10 months ago
Does anyone know how to generate random maps as in Age of Kings? Any source or tutorials would be helpfull!!
Mickey Kawick talk about this for about four pages in his "Real time stragey game programming" book.
btw, he worked on Age of empires.
One way to do it may be usi g fractals. You have a map fileld with water then let start somewhere with a land tile and let fractals branch out a fixed number of times at a fixed distance in a few random directions.each spot will repeat. and each spot will be filled with land tiles. The starting point of each fractal could be the starting point of the level, which will be random. After this have been repeated some times you will have a random shape. You can fill in the edges with shore tiles or whatever to make it look good. This is just one method. I hope it helped you!

Martin Björklund
Diemonex Games
Advertisement
I''ve been having problems with the same thing recently. I''m planning a Master of Magic type of game, that is a turn-based fantasy game, with lots of micromanagment. I''ve just made a simple engine so far that creates a random map and shows it using some graphics from Civ2:Test of time. It''s really slow, and the generated maps are not very pretty, but you can check it out if you want to:
www.cs.uit.no/~aslaks/tilegame/demo.zip

I created my maps something like this:

Initialize the whole map to water.
Create a variable for the percent of land on the map.
Create variables for how much of the land that are forests, mountains, swamp, desert etc.
Create variables for the amounts of starting "continents", and starting forests.

Calculate the number of land tiles you should create. (Landtiles = TotalTiles * Landpercent / 100)

Then, create x amounts of random points on the map, where x is the number of starting continents, and let them "grow" in random order. Dont grow the continents sequential order, because then all the continents will have the same size. The algorithm for growing the continents is just a matter of "moving" to a random nearby tile.
Keep doing this until you have the desired amount of land.

Then "smudge" the map some, to remove some ugly edges etc.

Do the same thing for forests, only that you only allow forests to grow on land tiles.

You can do this for mountains too, only add something that prevents them from growing too big.

I don''t have the code here right now, so I''m writing this from memory. Hope it makes any sense at all.
Hmm....I read an article on that very subject recently. I think it was on Gamasutra. If I run across it again I''ll post it up. The basic gist was how to create not only random maps, but using the quasi-random generator to create small data files that use only seeds to populate huge worlds with all kinds of information. I''m not doing it justice. I''ll go look for it....
A strategy I''ve employed a lot goes like this:

1. Create an array of heights for the map - set them all to a really low number.

2. Randomly apply some really big heights to random cells.

3. Run a smoothing loop, something like this:
for (smoothcount=0; smoothcount<8; smooth++)
for (x=0; xfor (y=0; ythiscellheight = average of all 8 adjoining cells height
next, next, next

4. Repeat 2-3 a few times. You''ll get quite nice continent shapes. Setting a sea level will help the effect.

5. You can then place realistic rivers by choosing high points as start tiles - and having the water flow to whichever adjacent tile has the lowest elevation.

6. I like to make really high tiles snowy. Personal preference.

7. Finally, for "virgin territory" if you place forests near water you get some really realistic type effects.

This works even if your final map doesn''t have heightmaps; simply export water tiles as water, land tiles as their appropriate type of land, etc. You get pretty convincing results - but it takes a moment or two to create maps this way. (I don''t have any good examples of this right now... left them in England. I''ve been using this for heightmap creation since the late 80s!)

This topic is closed to new replies.

Advertisement