As a summer project I decided it would be fun to make a Flash game. Right now I'm going for something like the look of Terraria. It's been a lot of fun, but today I've hit a snag. I need a way to generate my worlds. I've read up Perlin noise as a possibility, but I my attempts have given me sporadic looking results. What are some techniques used to generate these 2D tile-based worlds?

Ideally I would like to be able to generate mountains, plains, and caves.

  • 1
    \$\begingroup\$ Could you post some of your existing results? I'm not sure I can answer your question, but (a) I'm curious and (b) it might be easier to visualize the problem you're having/what needs to be fixed or improved if we can see where you're at now. Thanks! \$\endgroup\$ Commented Jun 27, 2011 at 23:17
  • \$\begingroup\$ What do you mean by "sporadic"? \$\endgroup\$
    – House
    Commented Jun 28, 2011 at 0:13
  • \$\begingroup\$ As Mitch and Byte56 say please expand your question, Perlin Noise is one of the common solutions, as is the related Brownian motion. For example Minecraft uses Perlin Noise en.wikipedia.org/wiki/Perlin_noise but ofcourse you have to do something with the random noise you get to make it look cool. \$\endgroup\$
    – Roy T.
    Commented Jun 28, 2011 at 10:39
  • \$\begingroup\$ Sporadic : Exhibiting random behavior; patternless. You'll need to smoothe the perlin noise out first, and think about what makes a terrain. Randomness is good, but if you want to generate a fun play area, you need specific rules as to what a fun play area is first. \$\endgroup\$ Commented Jun 28, 2011 at 14:39
  • 2
    \$\begingroup\$ Check out gamedev.stackexchange.com/questions/4628/… Most of what you want is fiddling with the output. \$\endgroup\$ Commented Jun 28, 2011 at 14:40

1 Answer 1


It sounds like you're looking to generate a "side view" of the generated terrain.

There are plenty of terrain generation algorithms discussed on the web. You could probably adapt many of them by cutting out all but one dimension from the calculations. This would give you information about the primary surface/underground boundary. If you want to be more directed in your search, you probably want to look for "1D" terrain generation or "Worms-style" terrain generation. You'll get results like this thread on procedural terrain (including caves), and this interesting web demo.

Perlin noise alone would work well for the areas where you want to generate plains, since it's very smooth. It doesn't work so well for mountains and craggy areas with sharp discontinuities -- you'd want to combine it with something else for that. Consider the first portion of this page on fractal terrain, or applying random cuts and displacements to the terrain.

Caves can be done by randomly punching holes in your terrain as a simple first pass, but you can also look for information on how rooms in Rogue-like games are generated and apply that. You might also consider looking into cellular automata.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .