Jump to content
  • Advertisement
Sign in to follow this  

Unity Procedural generation for 2d tile game

This topic is 1419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, i just joined you lovely community.


I need some theoretical help. I'm developing 2d tiled puzzle game, inspired by Minecraft mechanics a bit. Game is about digging down the procedural generated mine, collecting ores, avoiding monsters.


What i have done by now:


Level is just randomly generated of 3 different terrain types.


What i need help with:


I'd like to find a way to randomly select groups of tiles, which i will generate as rock type terrain, resembling rocks laying under ground. It should have random shapes and size, but close to circle, and have some distance between zones. 


Some my thoughts by far:


1) Find initial cell

2) For every neighbor of new cell, select this cell with chance depending on distance of this cell from initial cell

3) Recurse for every selected cell


I'd love to hear your ideas about zone selection and its placement around level.



Share this post

Link to post
Share on other sites

Here's a very simple approach:

Use perlin noise (always a good procedural content generation startpoint wink.png ) to generate the map and assign value ranges to certain materials, something like this

0.0 - 0.7 earth

0.7 - 0.95 rock

0.95-1.0 gems

Share this post

Link to post
Share on other sites



I've made experiments on a similar problem a while ago (biome placement on a procedural map). One alternative way for solving that type of problems could be to use a constraint solver like Google OR Tools. With OR Tools, you have to express the constraints of your system :


- My domain is a X*Y grid

- I want at most 25% of rock blocks

- Near a rock block there's 75% of chance to have a sand block


Set the seed, call Solve(), and you get a solution.


The main difficulty is to express the constraints, but I think it could be a very interesting approach, and can give a very good control of the generation.


Anyway, our actual generator is based on Perlin (GPU generation), and it works fine... Just an idea ;)

Edited by DTR666

Share this post

Link to post
Share on other sites

I'm a bit late on this post, but I'd suggest avoiding Perlin noise and instead using something I like to call OpenSimplex noise: https://gist.github.com/KdotJPG/b1270127455a94ac5d19 (An algorithm I designed for a currently-WIP game because I wanted to avoid both the artifacts of Perlin noise and the patent of 3D Simplex noise)


Perlin noise is an older algorithm that tends to exhibit significant grid artifacts by way of lining all of its features up with the cardinal axes and main diagonals. OpenSimplex noise should provide you with a bit more variety in the directions that your terrain features go. Perlin noise can certainly do some cool stuff, but what you can do with Perlin noise you can probably do better with a more visually-isotropic noise like OpenSimplex.


Perlin (top) vs OpenSimplex (bottom), 2D slices of 3D:



  • First is noise(x, y, 0) grayscale
  • Next is noise(x, y, 0) > 0 ? white : black
  • Next is |noise(x, y, 0)| < 0.1 ? black : white
  • Last is noise(x, y, 0.5) grayscale to illustrate that Perlin noise looks "weird" in non-integer slices
Edited by KdotJPG

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!