Random World Generation, Where To Start?

Started by
12 comments, last by timba 7 years, 3 months ago

Decided I want my game to use some sort of random world generation.

However I have no idea where to start.

I made a super simple generator which basically has a 50% chance to spawn a Stone or a Grass tile, and then it has a 80% chance to spawn a pink tile on the above layer of tiles : Grey = Stone, Green = Grass, Pink = Pink)

040eb52a47170b18e16cc01a384f640d.png

However,this is not at all what I want.

What I do want is a island which has a specific biome (like forest or desert, depending on what the player choose), and if it is a desert it should generate stone and sand, and sometimes (or rarely might be a better word) generate a "puddle" of water. But if it's a forest it should generate grass, trees and stone, mountains etc.

So depending on the biome the generation should be different.

I also want the island to be surrounded by water.

But I have no idea, at all how to accomplish this.

Advertisement

What you're asking is pretty complex.

Start with Perlin Noise (of the 2D variety). It has many important properties you'll want as you explore this field that the random noise you made above does not.

Creating a fully random, biome-laden world is very complex, and will involve many layers of this noise (and other kinds of noise) with all kinds of trial and error. There's no real cookbook on how to do it because it's mostly an artistic decision, but I can tell you that Perlin Noise is probably going to be your most fundamental building block. From there, it's a matter of figuring out how you want to modify and blend various noise signals together. There's literally an entire wiki on the subject, though it covers more than just world/biome generation.

What you're asking is pretty complex.

Start with Perlin Noise (of the 2D variety). It has many important properties you'll want as you explore this field that the random noise you made above does not.

Creating a fully random, biome-laden world is very complex, and will involve many layers of this noise (and other kinds of noise) with all kinds of trial and error. There's no real cookbook on how to do it because it's mostly an artistic decision, but I can tell you that Perlin Noise is probably going to be your most fundamental building block. From there, it's a matter of figuring out how you want to modify and blend various noise signals together. There's literally an entire wiki on the subject, though it covers more than just world/biome generation.

Yeah, thought it'd be complex, but now I at least know where to start.

And I'm surprised I didn't find that wiki, I've been googling for about 2 hours now....

Wow, that image really hurts my eyes. Can't look at it for too long or I might get a headache :P

About the topic, yes I agree with the previous poster that it's complex. I started looking at procedural generation a while back and there's so much too it if you want good results. As well as that wiki, there are other possible resources such as :

http://pcgbook.com/

http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

Might not have all the answers but will hopefully point you in the right directions :-)

I think you should do it more per-object, not just throw random over am ap.

As in: start with all water/flatland, then pick biomes, square or whatever concave (let's not complicate) shape, then start adding things, a circle/elipse for island (it'll sort of be like rasterizing a shape onto a bitmap), objects like towns or whatevers, etc. and then at the end trees, grass, whatever else that is per tile.

Start with the largest (biomes and islands) and end at the smallest (trees and individual resources on tiles) units that you are randomly adding. That's how I'd do it personally. You may or may not use perlin noise, it's not really necessary in my opinion... I mean, yes, minecraft uses 3D perlin noise but not every game that does random cities or terrain does, no way, you don't need that advanced math to do random generation of objects based on some criteria.

Also two links about the topic (first is more applicable):

Generating a simple city: http://blendogames.com/news/?s=urban

Generating a map from pre-made tiles: http://nothings.org/gamedev/herringbone/

It doesn't need to be Perlin noise, although that is a common algorithm these days.

Midpoint displacement is an easier algorithm and was quite common back when home computer speeds were measured in double-digit megahertz. It is fast and easy, then you can throw a secondary noise function on it like White noise (mostly flat) or Blue noise (fewer spikes) or various other noise functions. It is EXTREMELY easy to implement, trivial to implement with a recursive function (although recursion risks blowing your stack for big data).

Diamond Square is a more pleasing variation of midpoint displacement. Like above you can apply another simple noise function like White or Blue noise easily. Again, nice growth pattern and easy to implement.

Simplex noise is a little more complex than those above, and gives similar results to Perlin noise. It is faster than Perlin noise on large data sets, but scales worse than midpoint displacement algorithms.

Also you can invest time into terrain erosion algorithms. They'll help in making a heightmap look less random and more realistic. Although it wont work in Minecraft-style random generation, since thats on-demand based on a bunch of noise functions. Erosion algorithms work on previously generated data.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

It also depends on the architecture. Some algorithms are good enough for the CPU, and others run well on the GPU.
I think you would do really well if you are smart with noises. With enough stacked noise layers you can get really good results. Some people like cellular automata, I think Diablo 2 did that for the underground levels. There's also sampling (not so "procedural") but It looks really nice in space engine. Maybe you can also use Recursive Neural Networks, but I don't know anyone that has ever tried that.

Hey. Maybe you will like the procedural map generator I once programmed.

It basically creates various biomes and keep everything well connected and clean.

This one has a island:

http://i.imgur.com/Apzkx7i.png

This one has puddles of water:

http://i.imgur.com/KjP2aTk.png

you can also use Recursive Neural Networks

Hmm I could see this providing some interesting results but then the next question is how long to you run the network until you consider your map worthy of playing... Rhetorical question. Now I can't wait to get home and crack open some of my old AI algorithm books and start building some concept code.

This topic is closed to new replies.

Advertisement