A tile does not need to know what an entire town looks like to know that a road should meet another road. That small observation can carry a surprisingly long way. If one choice forces the next choice, and that choice restricts a third, local relationships begin to shape a much larger result.

Maxim Gumin's Wave Function Collapse explores this kind of generation. Despite the name, the practical mechanism is constraint propagation, not quantum computing. The important objects are possible patterns, compatibility rules and cells whose possibilities become narrower as decisions accumulate.

Begin with uncertainty

Suppose a small grid can contain grass, a horizontal road or a vertical road. Before making a choice, each cell may allow several options. Boundary conditions and neighboring decisions remove options that cannot fit.

Choose a horizontal road in one cell. A neighbor must provide a compatible edge. If that leaves the neighbor with only one possibility, the choice is effectively forced. Its other edges then constrain more cells. A single decision can travel across the grid before another random choice is needed.

A useful selection heuristic is to focus on a cell with relatively little uncertainty. Solving a constrained place early can reveal a conflict before the system spends time decorating easy areas. Pattern frequencies can influence selection without turning the result into a direct copy of the example.

The overlapping-pattern version makes the idea richer. Instead of assigning a semantic label such as "road," it learns small patches and which patches can overlap consistently. Local visual structure becomes the vocabulary from which a larger image is assembled.

A contradiction is information

A cell can end up with no legal options. This does not mean the computer has failed to be creative. It means previous choices and current constraints cannot all be satisfied.

Restarting or reconsidering choices is therefore part of the practical problem. More importantly for the designer, contradictions can expose a poorly chosen vocabulary. Perhaps the tile set allows roads to begin but offers no way for them to turn or terminate under the chosen boundary conditions.

I like the way this moves authorship into the rules. A designer can ask what kinds of connections should be possible, how frequently they should appear, and which arrangements should be impossible. The output becomes a way to inspect those decisions.

It is still possible to make a locally valid result that makes no global sense. A town may contain roads that never lead anywhere useful. Local compatibility does not automatically produce a good route, an interesting level or a satisfying composition. Those goals require additional constraints or a later design pass.

The algorithm is most useful when its promise stays specific: generate arrangements that preserve chosen local relationships. That promise is already substantial. A handful of carefully authored patterns can become a large space of variations. Giving those variations a purpose remains a separate design task.