This is The Mechanic, where Alex Wiltshire invites developers to discuss the inner workings of their games. This time, Unexplored [Steam page].

“Dungeon crawlers are very much the hero’s journey, where you start off as a nobody and end up as the big hero,” says Joris Dormans, creator of realtime dungeon crawler Unexplored. “Or at least that’s the plan.”

Unexplored creates great hero’s journeys. As Adam said in his Wot I Think, it consistently generates some of the best ever roguelike dungeons. They often feel like they’ve been laid out by hand, organic caverns giving way to rooms and corridors, each space sprinkled with foliage and architectural details, as well as puzzles, traps and obstacles to cross. And the thing that makes them feel so satisfying to crawl is something that calls back to the fundamentals of level design, and even architecture in general:

THE MECHANIC: Cyclic design

What makes for a good dungeon? If you talk to Dormans, it’s about pacing. If enemies are constantly thrown at you it’ll just feel like one big fight, so you want some quiet times of simple exploration and other things to do, like puzzles to solve. Making a dungeon out of different parts allows you to feel progression, because as you walk through it you get better – or your character does. And in a roguelike, walking through dungeons is your hero’s journey.

These ideas came from Dormans’ background in the humanities and specifically doing a PhD in game design. Having made games for as long as he can remember, he wrote a paper in which he made a detailed analysis of the dungeon design in the Zelda series. The aim was to build up a set of rules which dictate their form and to test then by creating a generator which attempts to replicate them.

As he worked, his ideas about level design grew and developed, and at the centre of them was one about cycles. It’s pretty simple: it says that interconnecting spaces are a good thing because they naturally bring you back to where you started, helping you to feel your character developing. When you return to familiar surroundings with a new item or weapon you tend to realise the difference between how you were before and how you are now, and get a handle on your hero’s journey.

And besides that, people like to be in interconnected spaces. “If I look at how my daughter experiences spaces, as soon as there are cycles and loops she starts running around,” says Dormans. “At a friend’s house she runs circles around it because it’s a well-connected space and enjoys that much more than our house which is basically a tree, a central hall with rooms coming off it. It’s not as interesting to walk around that space.”

After completing his PhD, he found himself participating in a workshop about designing a generator of parks in which you can hike. A walking simulator generator, if you will. On hikes you tend to circle back to the point that you started, preferring to avoid retreading your steps, and so he started to work out a system that used cycles as the structure rather than linear paths.

“That got me thinking,” he says. “In a dungeon, if you have a branching tree structure and you find a key at one end of a branch, you always have to traverse back. If there’s a cycle there, you can always go forward to get back to a point. That’s a completely different experience which is much better. You always feel like you’re going forward.”

Eventually he decided to make a game out of this concept, and that game is Unexplored. “It’s much bigger and more sophisticated than I’d originally anticipated and it’s got to the point that it’s getting very hard to control,” Dormans admits. ”It’s a huge system, based on rewrite grammars, and there are about 60 grammars in there with two or three thousand individual rules.”

The idea of interconnected dungeons really isn’t new, to the extent that Rogue’s dungeons were made of interconnected chambers. But Unexplored pushes the concept so much further, using locks and keys to give you reason to go off on a loop and return.

No, wait! Unexplored’s locks and keys are honestly great. Here, a lock can be a difficult enemy standing in your way, and a key a good sword hidden in a chest down the passage over there. It could be a corridor filled with lethal spikes and a lever to lower them. It could be a river of lava and a scroll of fire protection. It could be a room filled with spinning robots and a cloak of invisibility.

What makes them special is the creative aspect of the key, where as a player you have to interpret its use, and the way the different types of key have different fundamental properties. Some are one-use affairs; some are equippable items that you’ll get to keep. Levers change the state of the level itself. And there’s also the variable nature of the lock. Not all are impassible doors. Some locks are skill-based, so you might want to risk running them without trying to find, or use, the item that renders them harmless. And you might even already be carrying an item that will get you through a lock.

In other words, Unexplored’s locks and keys invite creative interpretation, skill and risk-taking, and they don’t feel as arbitrary as those in most games. And sometimes, you might mess up using them: you might swig your potion too early or not realise why it’s useful. For Dormans, that’s OK because of the player-centric nature of the roguelike. “If you beat the dungeon, you really beat it yourself. There are no save-games, no hand-holding. You did it, so it’s your victory and that’s really powerful. And to make sure that happens, you need this rough environment where you can make mistakes and they can be deadly.”

It’s also possible to become trapped in a room. Dormans regularly sees players exhibiting what looks like really stupid behaviour, where they’ll find a trap like a pressure plate, and then purposefully trigger it again. “I don’t know what it is; testing a theory?” But sometimes Unexplored serves up situations where this behaviour gets them trapped. For example, a room which slams all the doors closed when you enter and has a scroll of teleportation lying on the floor. Players can use the scroll, escape to safety, and then re-enter the room, whereupon the doors slam again, but they’ve now used the scroll and can’t get out.

“At that point it’s probably better to kill them, and I try to do that. There are some rooms with gargoyles that will kill you if you don’t get out within 30 seconds. Sometimes people make bug reports about getting trapped but there was a solution and maybe they didn’t see it. There’s a fine line between generator flaw and something they missed. Fortunately, people seem to have quite a lot of trust in the generator so they tend to try to figure it out.”

The generator works by starting out with a graph of interconnected nodes and lays down an entrance and sets up the first cycle: a lock and key and a path to go around. It then adds more detail to the level: a patrolling enemy, obstacles and items.

It decides what kind of lock and key it will be, often themed to match the level, such as lava for a fire-based level. It performs another pass to add more detail and decides what kind of space each room will be.

It then converts the graph into a tilemap of the dungeon level itself. Now it places individual items – traps, decorations, barrels – creates rock formations and the shapes of each space.

And then the level is complete.

The game begins generating the whole 20-floor dungeon while you’re on the character screen of a new game so you don’t realise it’s happening. But not before it’s made a dungeon plan, a separate process which lays out a meta structure to the dungeon, placing elements across the whole journey to give it an arc from levels one to 20.

There might be a fire dragon on level 12, so you’ll find a cloak of fire protection on level five. But it’s protected by a mini-boss, which might be weak to an item that’s hidden elsewhere on that level. It can also lead to sophisticated puzzles, such as a set of pedestals where you have to identify where to place one of a set of statues found elsewhere. There might be hints to how to discover clues to the solution for which pedestal and which statue: in the pattern of the flooring of a library, perhaps, written on a wall, or revealed with a glow only seen if you make the room go dark.

“It also allows me to do a lot of foreshadowing, which is interesting because it helps you plan ahead,” says Dormans. “One particularly nasty boss that can spawn towards the end is the Wraith Lord and it has a Sword of Slaying, which can kill you in one blow. Normally you wouldn’t get away with something like that, but the game makes sure there are hints beforehand that warn the player that it’s coming and has this sword, and tells you there’s an item that will ward you against that magic.”

Unexplored is interconnected outside of individual levels, a concept that makes its roguelike dungeon generation feel like a huge leap forward for the form. As for what Dormans wants to do next with it, he’s thinking much bigger.

“One of the things I’ve found out that it’s pretty boring to generate a sprawling dungeon like this,” he says. “It’s more interesting to have smaller dungeons that are more strongly themed, like distinct places, and I think it’d be interesting to put them in an overworld, and make it so you can travel the country and find dungeons with only two or three levels and strongly themed. That’s much more interesting to generate, and you can almost generate a history to it. That’s a step I want to take, using the same generative techniques and maybe some of the gameplay to make much more of an adventure story.”

On the evidence of Unexplored, that would be quite a hero’s journey.