# map/world “decorator” algorithms/patterns

I've spent a lot of time working with perlin/simplex noise for different styles of map gen, but I'm having a hard time finding advice/resources on how to populate the map with "world decor" that have some patterns to them... not just a random flower or tree.

I can control where on the map they spawn based on the height/temp values, but what are some good ways to control "patterns" the items spawn in?

For example, I want a specific plant to always spawn in clusters, but I want it to look natural and random - a bunch all together in a cluster and some individuals further out. I don't want all spawn instances to look the same.

A good reference is the Minecraft ore spawner - they're always in random configurations with some min/max size variations. Larger veins are even more rare.

There are multiple ways to do this:

1. When you want to place such an object you instead place a cluster centre, you then place a given number (random or pre chosen) number of decorator objects around this with a distance determined by any formula (normal distribution works well). The advantage of this is it' s ease to implements and it's speed. A good example of this is the following code:

float offsetx=nextGaussian()*deviation+basedistance
float offsety=nextGaussian()*deviation+basedistance

if (nextRandom()>0.5)
offsetx*-1
if (nextRandom()>0.5)
offsety*-1
placeitem(x+offsetx,y+offsety)


where deviation determines the spread of the items and the basedistance how much you want to prevent items from being very close to one another (creates a bit of a circle).

An alternative is to call this function again and again from each new object (with a change of it stopping)).

2. You can create a chance map, this is a map gives the chance of each tile containing an objects. You you make each of these positions into their own object you can put them in an array and shuffle them. When you place an object you can let it affect the chance of similar items appearing (either positively or negatively). The advantage of this method is that you can decide that an object increases the chance of a similar item appearing at a medium range while reducing the chance of a small range. Because you visit each tile in a random order you could even completely remove the chance element and instead use what would otherwise be the chance affect the size, this means that such a pattern has the biggest object in the middle. The advantage of this method is it's flexibility.

3. Pre designed patterns: the most predefined method you give a set of patterns and ask the computer to try and place those instead, useful for example when dealing with mushroom circles that have to be perfectly circulair.

4. complete simulation: by running a simulation of what proces creates the patterns in nature you can put them naturally in games, for example plants have a given range in which they spread their seeds and they make it harder for other plants to grow close to them. These two together will make patches of the same plant grow together but not to close, combine with plants preferring certain climates and you will soon get a very natural spread of plants (note that this does require you to balance nature as well as the game itself or else some of these things can go extinct).

• Do you have any good examples of the first item - I've tried this in the past but the random number of items "around" the current position wasn't using a good forumla, because I'd wind up too many holes close to the center. – BotskoNet Jul 23 '14 at 19:47
• added a bit of an example but sounds like you had to high a basedistance (which can actually be 0 depending on what you want or even -1 if your default gaussian implementation has 1 as the mean), or you had a to high a standard deviation (try making it lower). – Thijser Jul 23 '14 at 20:37