16
\$\begingroup\$

Here's the basic idea: I've got a Rogue-ish, perhaps Dwarf Fortress-ish game, with a randomly generated overworld and several dungeon entrances scattered around it. I already have the dungeons basically covered, but I'm stuck on an aspect of the overworld.

Said overworld, considered as a 2D map of screens, should have a perhaps blob-like distribution of four different themes or biomes -- grasslands, desert, snow and swamp, each with their own total amount of screens. Let's say the map is 8x8, which gives 64 unique screens. Half of those could be grasslands, a quarter desert, and swamp and snow get a quarter each:

mockup of a possible world map with towns and starting location, but no dungeon entrances

It seems palette reduction has made snow the same color as swamp. Originally, there were eight snow screens in the bottom corner, and a slightly staggered eight-screen swamp area in the middle. Sorry 'bout that, and please ignore the location markers.

The best I could get was some snaking shapes, and often enough with nonsensical combinations like desert snaking through snow (or vice versa). I can't for the life of me figure out how to get it nice and blobby, let alone having it make climatical (?) sense. So how do I generate a biome map like in the mockup?

Okay, by request: the world really isn't much bigger than that example, and what I need is just a way to spread some blobs that determine thematic appearances, with the extra limitation that snow can't touch desert. Screens don't scroll, and if a screen is set to "desert", there'll be no grass anywhere on it.

\$\endgroup\$
5
  • \$\begingroup\$ Are you willing to use third party libraries, or do you want to code your own solution? \$\endgroup\$
    – William
    Dec 4, 2011 at 20:57
  • \$\begingroup\$ I'd prefer coding my own. \$\endgroup\$
    – Kawa
    Dec 4, 2011 at 22:01
  • \$\begingroup\$ The biome sizes are fixed? \$\endgroup\$
    – kaoD
    Dec 5, 2011 at 1:07
  • \$\begingroup\$ Could you edit the post with a point list of the exact rules you want the map generation to follow? It'd be easier for us to deal with the problem knowing exactly what we're going for. \$\endgroup\$
    – William
    Dec 5, 2011 at 2:09
  • \$\begingroup\$ Edited, and the biome sizes, well, I went with those for example. For a 16x16 world, Desert could still be a fourth of the area and so on, but that's mostly to guarantee certain areas will be there. \$\endgroup\$
    – Kawa
    Dec 5, 2011 at 8:32

3 Answers 3

8
\$\begingroup\$

There are many ways to skin this cat, however one of the more interesting is using cellular automata. Begin with your empty grid and add a few seed starting cells in random locations. These should be of some basic non-mixed types of biomes. Say: Grass, Desert, Snow, Ocean.

Based on growth rules of your own design, which could feature some randomness (I don't care that it technically breaks the idea of CA, do you?) have them grown each step into the map. Additional rules can be such that if you are ocean and are next to grass or swamp, you might turn into swamp. If you are next to snow, you may become ice, if you are near desert, you may dry up and become desert too.

The same might be true for other mixes, and in theory even sub-mixes like frozen swamp, or tundra, or jungle sprouting from large expanses of forests that grew from large expanses of grassland.

The possibilities are endless, and can also be continual. As these rules are all simple, you can implement environments that shift over time. Combined with height information, and rules that take it into account, you can grow lakes and rivers, block the growth of forests over mountains and other fancy things.

That height map can be the result of perlin noise, or diamond square, or even whole other CA models. In fact, you could modify that map as time goes on as well by modelling plate tectonics, pushing up mountains, sinking in trenches, and even let rivers lower the landscape creating canyons.

This rabbit hole extends forever.

\$\endgroup\$
4
  • \$\begingroup\$ Upvoting for the CA suggestion. It meshes well with Valmond's comment. \$\endgroup\$
    – Kawa
    Dec 5, 2011 at 20:39
  • \$\begingroup\$ You'd be surprised how simple a CA solution can be to this problem. Simple rules and a random starting map can produce remarkably detailed and 'realistic' looking landscapes. \$\endgroup\$
    – DampeS8N
    Dec 6, 2011 at 3:09
  • \$\begingroup\$ Went with the CA principle. It's not quite right yet as the only thing keeping desert and snow apart are some absolute position rules, but it does nicely for now. \$\endgroup\$
    – Kawa
    Dec 6, 2011 at 17:24
  • 1
    \$\begingroup\$ One optional solution to the snow/desert problem is to have a rule in place to create a different type of biome where snow meets desert. Say, swamp. Then the swamp can continue to grow as normal. You still may have snow/desert borders, but in reality that's somewhat natural. In fact, most of the desert on earth is covered in snow. - in short, the snow might have the rule such that if any neighbor is desert, it changes into swamp. \$\endgroup\$
    – DampeS8N
    Dec 6, 2011 at 19:01
11
\$\begingroup\$

Short answer but you should really check this article out- www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ It explains one algorithm on the generation of the random generation of dry land and biomes based on designated humidity zones and altitude regions. But in your case, just set your own values for the distribution that you want.

(big edit) I will make this a much more clear for what map-generation concepts you need to apply. Use a coordinate system with 1 unit per screen, in floating point values. Generate a small random set of points within these coordinates, as if you were making a Voronoi diagram but we won't actually make the random shapes. Instead the diagram will be implied and approximated by the map after the biomes are set.

Each point is the center for each biome area. Set your own rules to associate a point with a biome. For instance if you want a desert to the east and not too far south or north, all points which are greater than a certain X value and within a certain Y range will have desert surrounding them.

Associate each screen with one of these point, which is done by taking the center of the screen in XY coordinates (say 4.5, 8.5) and returning the point closest to the screen's center.

Here's a rough drawing of a shape diagram on the grid of screens. We aren't really concerned with the lines surrounding the shapes, but they're there to illustrate how the screens start to approximate the shape regions.

Voronoi-grid

Repeat for each screen, giving each one its own biome.

\$\endgroup\$
6
  • \$\begingroup\$ I've seen that one before, and it's a bit too bazooka-on-a-mosquito for my tastes. \$\endgroup\$
    – Kawa
    Dec 4, 2011 at 18:42
  • \$\begingroup\$ Well okay, that's putting it mildly. It's very bazooka-on-a-mosquito. The 8x8 example wasn't just an example -- the world really isn't gonna be big enough to justify that solution. \$\endgroup\$
    – Kawa
    Dec 4, 2011 at 23:34
  • \$\begingroup\$ Okay, I see now. You're really not needing to differentiate the biomes to every single tile of the map. Also, the article's proposed concept does seem tailor-made to the author but some parts can be picked off. I'm editing my answer to make it more clear. \$\endgroup\$
    – ChrisC
    Dec 4, 2011 at 23:43
  • \$\begingroup\$ Still too complex a solution. There's no height or humidity to use here. All I need, all I meant to ask for was some way to kind of "spread out" blobs of desert, swamp, and snow up to the required amounts, following some extra rules like "snow can't get too close to desert". \$\endgroup\$
    – Kawa
    Dec 4, 2011 at 23:52
  • \$\begingroup\$ @Kawa: Seems like you're ready to dig in and write your own solution! From what I can tell, you've got it all visualized in your mind, just DO IT! :) Remember that it doesn't have to be the ultimate map generator in the world, as long as it LOOKS like it is. ;) \$\endgroup\$
    – Zolomon
    Dec 5, 2011 at 23:31
1
\$\begingroup\$

Answer 1:

grow snow and desert, when that is done, seek the (forbidden) intersections and grow (more or less big) swamp there.

Rince and repeat.

Answer 2:

For the 'blob' part, I moved my comment (as requested) to the post:

If you grow around by iteration, ie. set out 1 point of desert and then randomly grow around any desert point (each time randomly take one of the existing desert points and add 1 point on one of its sides (where there are nothing yet)) then you should get a blobby effect (no long lines for example).

You can also add a rule so you can't create a desert tile if there is snow on any tile nearby it.

\$\endgroup\$
4
  • \$\begingroup\$ That doesn't exactly help with the blobby aspect of the problem. \$\endgroup\$
    – Kawa
    Dec 4, 2011 at 19:42
  • 2
    \$\begingroup\$ if you grow around by iteration, ie. set out 1 point of desert and then randomly grow around any desert point (each time randomly take one of the existing desert points and add 1 point on one of its sides (where there are nothing yet)) then you should get a blobby effect (no long lines for example). \$\endgroup\$
    – Valmond
    Dec 5, 2011 at 12:34
  • \$\begingroup\$ you can also add a rule so you can't create a desert tile if there is snow on any tile nearby it. \$\endgroup\$
    – Valmond
    Dec 5, 2011 at 12:40
  • \$\begingroup\$ Valmond, put that in an answer. \$\endgroup\$
    – Kawa
    Dec 5, 2011 at 18:23

You must log in to answer this question.

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