The Logic of Procedural Generation

Dan Schatzeder
6 min readMar 19, 2021
Cellular automata procedurally generating, through Perlin noise, that which looks to be a landscape

Procedural generation — a broad and massive topic that can seem intimidating at first, but whose fundamentals can easily be grasped and replicated. It is the algorithmic creation of data, or more simply, an automated process with a set of governing rules.

You will have seen this via landmass or level generation in popular video games like Minecraft, Spelunky, and No Man’s Sky, to name a few. In animation, Lord of the Rings used proc-gen to simulate its armies, and the Mandalorian uses it to produce landscapes. Outside of computers, nature has its own processes by which ordered logic is executed.

The important concept to grasp here is: processes following rules, or rules that we follow.

Think of how you’d shuffle a deck of cards. You might take some cards from the ends and put them into the middle, or fan two stacks of cards into one, or spread them out on the floor. Your shuffling process follows rules to achieve your result, the perception of randomness. The same goes for all procedural generation processes, just with more rules.

One early and powerful implementation of procedural generation uses cellular automata to display seemingly organic patterns and structures. It’s called Conway’s Game of Life¹.

An infinitely repetitive process in Conway’s Game of Life. Using Gosper’s Glider Gun, we can see that certain shapes of cells, called oscillators, will periodically return to their original state.¹
Following four simple rules, Conway’s Game of Life begins to simulate what appear to be organic and living structures!¹

A cellular automata is a grid of cells, with each cell having a finite number of states such as “on” and “off”. The Game of Life is an incredible demonstration of the potential of procedural generation using cellular automata. Following four simple rules, each cell’s fate in the next “generation” is decided by its neighbors.

Break out of computers for a second and let’s take a look at how some of the rules in the Game of Life govern our very selves in nature! Take this study on the ocellated lizard for example.² As a lizard ages, its skin begins to take on a different pattern of pigmentation. Looking at the adult lizard (B), we can see a labyrinthine pattern has emerged from a spotted one (A). There must be a set of rules through which one pattern emerges from another. We don’t have to know all the rules to grasp the significance, just look at slides H and I. Look familiar? Certain cells have de-pigmented because they were deemed as having too many neighbors. Conway must have drawn inspiration from natural processes like these.

H becomes I after making certain measurements, one of which is each cell’s number of pigmented neighbors. The two cells that de-pigment are considered overpopulated by the lizard’s rules.²
Adapted simulation of the type of process the scales undergo to emerge from a spotted pattern into a labyrinthine one.³

Back to computers… How can we extend this logic in a useful and demonstrative way? Let’s take our cellular grid, our basic Conway rules, and add to each cell in that grid an initial chance to activate. You can study and tinker with one such demonstration, and even code along to make your own in Unity in the link below.⁴

Out of apparent chaos, our rules cause the cells to behave in a seemingly organic way toward one another. With each click, or generation, isolated cells deactivate and structures attract additional cells.

We can start with a grid of randomly activated cells (think noise) and through each generation of our procedure, they begin to take on a seemingly organic structure. To further demonstrate the value of similar processes, let's take a look at what's called Perlin Noise.

Perlin noise is a type of coherent and gradual noise used to visualize realistic and organic appearances. Just like our randomly initialized grid of cells but:

  • Instead of cells being “on” and “off”, we have values ranging between 0 and 1, best referred to as height (think darkness, or intensity)
  • The cells follow the ever familiar rule of gravitating towards one another and not existing in isolation or excess (neighbor rules)
  • Lastly, neighbors have a tendency not to change from one height extreme to the opposite, except in a gradual manner: something of an extension on our isolation rule. Notice the transitionally fading appearance.

It might look nonsensical still, but let’s make use of this by coming full circle. One series of incredible Unity tutorials later⁵, we can coordinate the height values in our Perlin noise map to colors in a familiar pattern, like landscape.

We take a map like the one above, and we make some decisions on which values should be what color.

Remember our values range from 0 to 1. Start with our two geographical height extremes: deep seas and mountain peaks.

Assign colors and values to everything you want in between: shallow water, beaches, land, rocks, mountains.

Watch our coherent noise map turn from chaos into a familiar appearance.

A variant of Sebastian Lague’s landmass generation tutorial. Very worth watching and following along to, link below.⁵
Using the same 2D Perlin noise maps and values, our height indexes can then dictate actual height in addition to color, imitating a 3D landmass — via Reddit

From the appearance of chaos, through the obedience of a set of rules, comes the appearance of order.

One last important thing to note regarding the simulation of randomness is the concept of seeds. Through the use of seeds, we can dictate to our simulations the order in which they randomize their behavior. Using a seed, you can control and store results, which is useful in:

  • Debugging procedural logic by reproducing and analyzing
  • Saving random results in video games for multiplayer competition
  • Storing massive worlds just by saving their seed and the algorithm that produced them. Think of an entire galaxy, reproducible by merely plugging in an integer.
With a specified seed, we can reproduce identical results.

When it comes to procedural generation, remember what was reiterated most here.

  • Sets of governing rules with which we can automate processes
  • Maps or grids populated by cells who have some defined value
  • Organic neighbor rules: Cells attract other cells, they mostly do not exist in isolation, and they tend only to change gradually

When you observe an organic structure in nature in the future, try to pick out a few of the rules they followed to arrive at their result

It is well worth diving into any of the tutorials or articles listed below if you’re interested in learning about or doing this yourself. This only scratches the surface of procedural generation. It’s important though, not to forget, that whether it’s leopard spots, honeycombs, fish scales, lava, camouflage, clouds, or landmasses, it’s a set of governing rules that can be picked apart and imitated if done carefully.

1 — Jim Conway’s Game of Life

2 — Manukyan, L., Montandon, S., Fofonjka, A. et al. A living mesoscopic cellular automaton made of skin scales. Nature 544, 173–179 (2017).

3 — The ocellated lizard is a computer game come to life

4 — Generate Random Cave Levels Using Cellular Automata

5 — Sebastian Lague’s Procedural Landmass Generation Tutorial Series