Every Bewildoor level is generated, including the twenty campaign levels per difficulty, the endless mode and the daily maze that the whole world plays. A generated puzzle game has two jobs that pull against each other: every level must be solvable, and it must not be solvable by accident. Here is how the generator handles both.

The rules the generator has to respect

In Bewildoor you carry clue sets (crayons, number cards, symbol magnets, phrase notes) and arrange each set into an order. A door marked with a value opens only if that value matches the next item of the same kind. Walking through spends the item; walking back through the same door returns it. That last rule matters a lot for the generator, because it means the player can always undo a mistake. The danger isn't getting stuck forever. It's a level where a lucky guess works just as well as careful thinking.

Step 1: sections and regions

A level is made of one to four sections stacked from south to north. Each section is a rectangular region of rooms on a grid, with the puzzle room in the bottom row and the exit in the top row. Doors of a section only matter inside its region, and the exit door seals behind the player, so every section can be generated and checked on its own.

Step 2: carve the intended route first

Before any other door gets a value, the generator picks the clue sets for the section and a correct order for each, then carves one route from the puzzle room to the exit. The route has exactly as many marked doors as there are items to spend, and each door along it gets the value the correct order needs at that point. That guarantees at least one solution. It also means the solution walk is known, which the automated tests use later.

Step 3: fill every other door

Now the rest of the region is filled in. Most rooms get three or four doors (about three quarters of all rooms), so there are many possible paths. These extra doors get values drawn from the same clue sets, which is what makes the maze hard: from inside a room, a door on the correct route looks exactly like a door that leads nowhere useful.

Step 4: make sure guessing doesn't work

A maze where any order reaches the exit is boring, so the generator tests its own work. It tries many random wrong orders and runs a breadth-first search for each one: starting from the puzzle room, which rooms can a player reach if they follow the door rules with that order? If too many wrong orders still reach the exit, the extra doors are thrown away and filled in again.

How many is too many depends on the difficulty. On Easy, up to half of the random wrong orders may still work, so a beginner who is close to the right idea gets through. On Normal it's 30%, then 20%, 15% and 8%, down to only 4% on Impossible. In practice the dense mazes usually end up far below those limits; in our test runs around 0 to 2% of random wrong orders reach the exit.

Step 5: gates, goals and decoys

On top of the basic maze come the gates between sections (riddle rooms, room switchers and combination locks), extra goals on the harder difficulties, unreachable fake goals, decoy clue sets and fake hints. Each of these needs its own rules. For example, nothing on screen may ever reveal a riddle's answer, so a goal behind an answer door gets no beacon or minimap dot. Every new kind of gate also has to keep the generator's list of solution rooms correct.

Same maze for everyone

Daily and weekly challenges, live races and ghost replays only work if every player gets exactly the same maze. The generator is driven by a seed, and nothing outside the seed and the level settings may change what it builds. Our remote configuration can change links and presentation without an app update, but it is never allowed to touch level generation.

Testing hundreds of levels on every change

After every change to the gameplay or the generator, an automated test builds hundreds of levels across all modes and difficulties. For each one it checks that the level can be solved with the intended orders, that walking back really returns every item, and that passages between rooms work the same in both directions. It also prints statistics about door counts, which is how we keep an eye on the "three or four doors per room" target. A second test plays real levels from start to finish and opens every kind of panel in the game.

What we learned

Early versions were called "too complicated and confusing" by testers, and they were right. The first mazes had endless wrong branches and rescue mechanics. The fix was the rule that every wrong door spends an item: wrong turns run out naturally, and the player walks back. Easy and Normal also got smaller mazes, full hints and a warning when the current order can no longer reach the exit. A generator is only half the job; the other half is deciding what the player should feel when the generator says no.