Advanced procedural map generation?

[I was going to post this as a reply to @WhiteBoxDev 's tutorial topic (Game Development Tutorials and Defold YouTube Videos) but I decided to start a fresh topic instead as I don’t want to hijack his. I recommend taking a look at it, the videos on procedural generation are great.]

I’ve finally taken a moment to have a first look at procedurally generated maps. I’ve taken a peek at Klayton’s Fractal Noise tutorial and source code. I have to say it’s a really excellent example, and it’s surprisingly easy to understand. Well done on all counts.

TL;DR: Fractal Noise is used to procedurally generate maps such as this:

I’m starting to extrapolate in my mind and I wonder if anyone has any thoughts or resources at hand. I promise I’m going to put in the legwork myself, just curious if you have any input!

First thing I’m thinking of, is how do we go about manipulating the noise to fit a certain type of output that we desire? From my experimentation, it does seem like you can get quite far just by tweaking the variables included in the example. But if we want really specific types of terrain, are there more advanced techniques? Thinking of something like running multiple passes of procedural generation from low resolution to high resolution - for example first creating a split of walkable / non-walkable areas, then doing another pass of generation to make those more interesting.

Another thing I’m thinking of is things like symmetry. For example, if we’re creating an RTS map for two players, we’d want to create two similarly bountiful patches of resources next to their respective starting locations. How do we do that? Or things like placing treasure chests - how do we place those in locations that make sense?

Again, I’ll do research and experiments myself as well, just curious if anyone else has gone down this path before.

8 Likes

Squirrel explains this in his detailed presentation, and he uses noise based RNG, in fact he uses a hash function to generate the noise.

I used this idea to generate terrain patches using the deterministic behavior in my defold-terrain (Note: Very WIP!)

E.g. I generate a height seed for the terrain.
The, using that seed, I can generate the heights for that patch by using the noise function.

The height seed is shared in order to be able to generate the continuous terrain.

For other things, like spawning patterns, you might want to use the patch X/Z as the spawning seed, in order to make the behavior deterministic for that patch.

My plan is still to put the rng+noise functions into a separate module with Lua+C++ support.

9 Likes

Thanks for the kind words, really appreciate that. And I’m glad to see you found the example understandable and useful.

When it comes to generating terrain and other features procedurally, there’s never a one-algorithm-fits-all approach. You will always find yourself layering many algorithm over top each other. For example, use cellular automata to generate a cave system, use fractal noise peaks to generate randomly placed items, use diamond square to generate a height map, etc. (Those are just examples, I don’t recommend using them exactly like that and there are plenty other algorithms to consider).

2 Likes

Thanks to both of you!

@JCash - I look forward to watching Squirrel’s presentation!

@WhiteBoxDev - since I posted I watched your video on cellular automata. This already started giving me ideas, e.g. for an RTS map you could use fractal noise to generate the bulk of the terrain, then dab a couple of resource tiles on either end of the map and use cellular automata to expand those into small fields of resources.

Seems like I need to consume information and use it to brainstorm unique methodologies.

3 Likes

The result of a little bit of experimentation.

A two player RTS map with two sections of resources (yellow).

I used Fractal Noise to generate the terrain. Then I placed two red dots on either side of the map to signify starting positions. I used a few basic constraints like the dots having to be on either side of the middle of the map, and not be close to the the edges or the middle.

Then I used a modified cellular automata ruleset to expand yellow resource tiles out of the red tile.

Just from this little experiment I realise just how much opportunity there is to customise the procedural generation to fit whatever it is you are trying to accomplish. It’s tricky to get just right, but this stuff is FUN.

7 Likes

You also have other options to create the terrain. E.g. creating a voronoi grid, that gets you different regions that can be used to create a map:
Polygonal Map Generation for Games (There are many ideas on his site https://www.redblobgames.com/)

2 Likes