• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Perlin Noise for Random Map Generation with different Map Types

Anixias

Member
I have written a set of scripts and a "class" called class_perlin. Basically, I call randomize() or random_set_seed(), then instantiate the perlin class. Then, I can access any location in the generated perlin noise. I can also set a "static" variable called noiseRepeat to anything above 0 if I want the perlin noise to wrap around after noiseRepeat distance.

It works perfectly! It has octaves, and I have a persistence function to deal with the weight of each successive octave. My only issue is that I need it to be modifiable such that the generated perlin noise follows specific rules without fail.

I'm using this perlin noise as a heightmap in an isometric RTS game. The generated perlin noise does not have any rules at all yet. I could easily add brightness and contrast to it, and keep increasing the brightness until I have the desired amount of land (water being anything below 30% brightness). However, I have many more needs than simply that.

If I want the map to be an island (or chain of islands), I can simply multiply a radial gradient (white in center, black on edge) across the whole map, and the edge is always guaranteed to be water, and if I multiply the whole map brightness by a certain scalar, I can ensure a certain amount of land with water always on the edge.

But, what if I want to ensure, every single time, that the generated map has at least one island per player, and that this island is large enough to allow expansion, and always has a specific amount of resources, and that there could be other random smaller uninhabited islands?

Or, what if I wanted an island for every team in this game? And that they are always big enough and far enough from other islands, and always have a specific minimum resources?

Think of Age of Empires 2, or Civ5. These games have map types, like Continents, where a few huge islands are generated and players are nearly evenly split amongst them. What if I want a map that is all land, with some rivers?

How could I modify the generated perlin noise to ensure that they follow any rule I could come up with? Of course, I won't be modifying how the perlin noise is actually generated at all. I would just modify what I read from it.

tl;dr
How could I use my perlin noise to create maps using different map types as in Age of Empires 2 or Civilization 5?
 

NightFrost

Member
I'm interested in random continent generation so I've been toying around with Perin noise as well, up to testing single continent generation where, as you describe it, the noise is faded out towards the edges to ensure a sea encircling the land. What follows is theoretical "what I'd like to try out some day:"

For multiple continents, I'd pick random start location from map. For competitive multiplayer you'd make sure they're spaced far enough from each other. Then I'd define initial landmass shapes by some random walk algorithm that is biased towards the start location - the further it goes, more likely it is to turn back towards start. The random walk would run for a number of steps that has been observed by number of tests to have a good chance of generating a landmass of at least X tiles. You could ensure minimum landmass sizes by counting the number of tiles connecting to the start point. During the random walk, each start point keeps book of furthest north/east/south/west distance the walker moved into.

For each landmass I'd pick the starting point and few more tiles near it, or perhaps several clusters, as peak points. These would be faded towards zero moving outward, using some estimated values from the north/east/south/west extents recorded above. This probably wouldn't create smooth shores and would need to be refined further... Finally, this landmass heightmap would be combined with a Perlin noise map. This would hopefully create a map with several landmasses.

Rivers would be easy enough. Pick a tile that is high enough, and have it flow to a neighbouring tile that has the lowest elevation. Repeat until lowest point has been reached (shore or a land depression).

For random resource placement, since you have landmasses' maximum coordinates on record, just pick randomly from them, check you hit dry land, and place a resource. Repeat until there's enough.

There's probably some problems with these that I haven't considered, since none of these is something that I've tested.
 
K

Kululu17

Guest
I'm actually curious about the river thing as well. The problem I see is that if you move from a high point to a low point, you could get "stuck" at a point that is a locally the lowest point around, but not the overall lowest point. I was thinking that working backwards from the lowest point, and then picking the surrounding point that is the lowest point among those that are still higher than the point you are currently at might solve this problem.
 

Anixias

Member
For multiple islands, I could set the map to black, and generate a bunch of smaller perlin noise squares with white-to-black circles on then, and move them around on the map.
 
Top