Every tile earns its place: inside Plumb's level generator

How Plumb's levels are made: random boards, a solver that sets the goal, a test that each chapter's rule matters, and a pass that strips tiles the best route never needs.

A Plumb board seen in perspective, its walls standing up as slate blocks among the marbles, with one one-way gate tile lifted high above its empty slot on dashed guide lines

A player pointed out gates that did nothing. They were right. Take such a gate off the board and the level plays exactly the same, so all it adds is a puzzled player looking for its point. When I checked the whole game, a little over half the levels from chapter 5 on had at least one tile like that.

This post is about how a Plumb level is made, and the pass I added so that every tile on a board has a job. Proven solvable sets out how all three of our games build their levels, so here I stay with Plumb’s own machinery.

A recipe, and a lot of rejection

Each chapter is split into phases, and each phase is a recipe: a board size, how many colours and marbles, how dense the walls are, how many pits, which tiles to place, and a window the goal has to fall in. The generator follows the recipe at random, and most of what it makes is useless. A cheap check throws out any board where open floor does not even connect a marble to the hole of its colour. Whatever survives goes to the solver, which searches every tilt, layer by layer, for the shortest way to clear the board. If that length falls inside the window, it becomes the level’s goal, which the code calls par, after golf.

The rule has to matter

From chapter 5 on, every chapter brings a new tile, and a random board with a stop pad on it will often solve just as well without the pad. A level like that teaches nothing. So every candidate is solved again with the chapter’s tiles turned back into plain floor, or its plugs into ordinary holes, and kept only if that plain board has a different goal or no solution at all.

The test has to look both ways. A rule that helps, like a stop pad, shows up as the plain board getting harder, and a rule that restricts, like a one-way gate or a plug, shows up as it getting easier. The first version only looked for harder, and since taking a plug away only ever gives the marbles more room, the plugs chapter all but stalled, with a handful of boards from 15,000 attempts.

Then every tile has to matter

Needing the rule as a whole still lets single tiles slip through: two gates where one does the job, or a pad that no route ever touches. So before a candidate is judged, the generator takes each single-cell tile off in turn, from stop pads and gates to springs, magnets and glass, and leaves it off if the goal stays the same.

It goes round more than once, because taking one tile off can change whether another matters. Of two gates that block the same shortcut, the first one tried is idle while the other stands, so it comes off, and that makes the second essential. A tile kept earlier can also stop mattering once another has gone, so the pass repeats until a full round takes nothing off. Tiles that work in pairs, like twin portals or a key with its locks, are judged by the rule test as a whole instead.

The obvious fix was to clean the finished levels afterwards, and it does not work. A tile that never changes the best route can still block wrong ones, so taking it off can make a board easier to stumble through. One level dropped from 15.1 to 11.6 bits, the game’s measure of difficulty, when its idle tiles came off, and a clean-up after the fact could fix only 126 of the 217 levels that needed it without some level becoming easier than the one before.

So the pass runs on each candidate before it is measured, and every board is judged exactly as it will ship. That is expensive: the cracked floor chapter at first found just 4 usable boards in 15,000 attempts. Every chapter from 5 on now tries three times as many boards per level, spread across several processes and seeded so that the same seed always writes the same levels. Every level from 81 on was made again this way for version 1.1.3.

No level twice, even when the walls differ

Two boards of one size must differ in at least 30% of their cells, compared in all eight turns and mirrors. Plumb adds a second rule: if one board’s shortest solution, turned to match, also clears the other in the same number of tilts, the two must differ in at least half their cells. Short solutions come in very few shapes, since up to turning and mirroring there is one solution of a single tilt and only two of two tilts, a turn or there and back. Two sparse boards that both solve with “right, then down” play the same even when their walls look different, and an early version of the game had such a pair only 2 cells apart out of 16.

An order that never gets easier

Every candidate is also measured in bits: how unlikely a player tilting at random would be to clear it in exactly the goal. Why four directions go so deep works through an example. From each phase’s pool, a small search picks the run of levels that best follows a target curve, under hard rules:

  • The goal never drops from one level to the next, chapter starts included.
  • Up to chapter 10, bits never drop either. From chapter 11, where asking for both left the pools almost empty, the goal comes first, and bits only have to climb within one goal.
  • No more than five levels in a row share the same difficulty.
  • Within a chapter, no level takes away room, a colour, a marble or a pit.

A step chart of the goal for each Plumb level in order, climbing from 1 to 21 in small steps without ever dropping

Levels 1 to 5 get extra care. A separate step picks them for what they show a new player, such as a long roll home or a tempting tilt that costs a move, and scores them for how tidy they look as well as how hard they are. Learn Plumb in one board walks through them.

What the tests hold it to

Whenever the game changes, the tests reread every shipped level and check the promises from the boards themselves: every level solves in exactly its goal, no two are the same or near copies, none is easier than the one before, and every pit level has a pit in play. A generator can have bugs, and a test that reads the finished levels catches them anyway.

Our other games solve the same problem differently. Carillon grows its fields from roots, and Apsis builds its levels backwards.

On this page