Procedural generation for 2d tile game

Started by
3 comments, last by KdotJPG 9 years, 4 months ago

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:

[attachment=24773:1.png]

Level is just randomly generated of 3 different terrain types.

What i need help with:

[attachment=24774:2.png]

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:

[attachment=24775:3.png]

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.

Advertisement

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

Try to research "Cellular Automata"

Hi,

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

etc..

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 ;)

----

www.winthatwar.com

Download our latest demo here.

www.insaneunity.com

@InsaneUnity

@DTR666

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:

Perlin_vs_OpenSimplex.png

  • 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

This topic is closed to new replies.

Advertisement