27
\$\begingroup\$

I'm looking to create a simple, "randomly" generated map for a small game.

The game consists of a top-down view of a world, with land-mass and ocean areas. Think of a simple outline map of the world for example.

The closest thing I can think of that I've seen before was the level-generator for the old SimCity games, or the Civ series, where you can set a preference for single continent versus many islands, etc.

What sort of algorithm would be suitable? The map will need to be moderately zoomable, so I can have a "whole world" view, and also a more zoomed-in local view, but I think I'll sort that out later.

Initially I don't need any concept of heights, just two areas - land and sea, although I might extend it later.

\$\endgroup\$
1
  • \$\begingroup\$ I was thinking along the lines of generation using a perlin-noise function of some sort, but am not sure how to get from what is essentially a 2D heightmap, to a set of lines connect all areas at height X. \$\endgroup\$
    – Cylindric
    Sep 22, 2010 at 14:20

1 Answer 1

21
\$\begingroup\$

The "famous" Amit (with the giant page of various game programming topics) has a game programming blog, and he just completed a 3-part tutorial of an interesting method of map generation. I really enjoyed the reads, and there's a working demo in the bottom of the third article which is pretty stellar.

"Polygon map generation" part 1, part 2, part 3.

This may be a technique that you want to adapt to your needs! At the very least, he mentions the algorithms he uses at each step of the process: he starts by generation Voronoi polygons, relaxes them to a more even distribution using Lloyd relaxation, uses "a simple function to divide the world into land and water", and then flood fills to determine oceans and lakes. It sounds like you can stop there, or read on for mountains and valleys and turning it into 3D and so on.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Oh wow, I used Amit's guide a huge amount to learn A*. It's like he looks into my head :) Time to get that "<3 Amit" tattoo... \$\endgroup\$
    – Cylindric
    Sep 22, 2010 at 15:38
  • 1
    \$\begingroup\$ Those are really freakin great \$\endgroup\$
    – Colm
    Oct 19, 2010 at 22:21
  • \$\begingroup\$ Voronoi, nice. :) \$\endgroup\$
    – user712092
    Jul 4, 2011 at 15:02

You must log in to answer this question.

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