Sign in to follow this  

Random World Generation, Where To Start?

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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....

Share this post


Link to post
Share on other sites

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/

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Edited by RenzoCoppola

Share this post


Link to post
Share on other sites

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

Edited by timba

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

An interesting question nonetheless. I don't know if generation should be slow, maybe I even got it wrong with the RNN thing, there're a craptong of architectures: I draw the CPPN card (just a bunch of stacked sines, cosines, and similar functions that recieve coordinates). 

Edited by RenzoCoppola

Share this post


Link to post
Share on other sites

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

 

I would like to look at the source code of that, if that's possible.

Share this post


Link to post
Share on other sites
Posted (edited)

 

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

 

I would like to look at the source code of that, if that's possible.

 

 

Totally.

 

I used Unity and this is how I created maps manually: Pressing some booleans and playing with the numbers.

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

The magic boolean is used to create a map automatically, using a heuristic that I created to generate maps of my liking.

 

Code: http://pastebin.com/zb7Kkmxg

This is not one of my best codes... It is poorly commented, sorry.

(Keep in mind that this code uses another classes from my project, like Map, GameManager and Tile.)

Edited by timba

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this