27 January 2016

Puzzles have been on my mind a lot recently. The MIT Mystery Hunt was less than two weeks ago, and The Witness was released yesterday. Last week I wrote about my experience at Mystery Hunt, and I'm sure I'll be writing about my experience playing The Witness in the future. Because of that I wanted to write down some general thoughts on what makes a puzzle well constructed.

The Must-Haves

Missing one of these qualities will generally make me feel that the puzzle is poorly written, regardless of its other qualities.

If you have all the information, then you can extract the entire answer.

I think this is the single most important quality for a puzzle to have. In fact, I think that it's fair to say that this is what separates being a puzzle from merely being obtuse. Imagine if someone asked you "What is 3 plus 5?" and told you that everything you say is wrong. Eventually, you give up and they say that the answer was "Banana". Was there a reason for the answer to be "Banana"? Why not "Apple"? Why not "BANANA"? Why not "8"? If there isn't a reason for the answer, it's not a puzzle.

The puzzle is internally consistent.

This is more or less what it means for a puzzle to be "fair." When you throw out consistency, you're moving away from being a puzzle and moving toward communicating badly. For example, if the puzzle uses "The Hitchhiker's Guide to the Galaxy", it shouldn't also use "Tales of Beedle the Bard, The". Ideally, if there's more than one possible convention, the puzzle gives some indication of which to use, but the most important thing is that it sticks to just one convention.

The puzzle is meant to be solved.

One misconception that many people have when they start writing puzzles is that their goal is to somehow defeat the solver. If one of their testsolvers finishes quickly, their reaction is to try to make the puzzle harder. Many times, they make the puzzle more difficult, but also significantly less fun.

A good puzzle is designed with the solving experience in mind. The author's goal should be to craft that solving experience to be as rewarding as possible. Difficulty is just one of the tools available, since one of the most rewarding feelings is reaching a breakthrough point after a long struggle. However, that breakthrough needs to actually happen in order to feel rewarding. It is easy to make a puzzle that nobody will solve. The real challenge is getting the solvers to struggle that perfect amount so until they break through with the feeling of triumph.

The Nice-To-Haves

If I notice a puzzle missing one of these, I will be unhappy about it, but it can still be a great puzzle if its other aspects are well done.

It is more valuable to think about the information you have than to blindly try things.

The purpose of a puzzle is to make the solver feel accomplished when they solve it. If a solver starts doing things at random and then is told that something they did solved the puzzle, then they aren't going to feel like they accomplished anything.

To have this quality, a puzzle should have a much narrower solution space than possibility space. That way a player's random actions are so unlikely to find a solution that they need to stop and think about the problem at hand. That said, there are multiple ways to create that situation.

SpaceChem is a game where you build machines that take in molecules made of atoms that are bonded together, perform some operations, and then output new molecules on the other side. Every puzzle in SpaceChem has many different solutions, and yet if you place down pieces without thinking, you'll never hit one. That's because while the solution space is quite large, the possibility space is so enormous that it doesn't matter.

Snakebird is a game where you guide snakebirds around a grid-based level to eat fruits and then to the exit. The possibility space is much smaller than that of SpaceChem, since each action involves moving a snakebird's head to an adjacent cell. However, the puzzles are expertly crafted so that there's usually something you have to get just right, like having a snakebird is exactly the right shape and facing the right direction, or else the rest of the puzzle will be impossible. The solution space isn't narrow the whole way, since usually your snakebirds have a decent amount of maneuverability at the beginning and end of a level, but there's that one section that's so narrow that someone trying random things is unlikely to hit upon it.

Nikoli is a puzzle company that has created many types of logic puzzles, most famously Sudoku. They go to the extreme of making the solution space narrow: every puzzle has a unique solution. In addition, they design their puzzles so that there's a chain of logical deductions from the starting state that builds up the solution piece by piece. Usually no trial-and-error is necessary. That combination means that trying random things will not be as useful in finding the solution as looking for those logical deductions.

Every step of the solution is motivated.

Nikoli is a great example of puzzle writers who take this idea to heart. Like I mentioned above, Nikoli puzzles are designed so that solving them involves finding a chain of small logical steps that builds the solution up piece by piece. As a solver becomes more skilled, they'll learn to recognize more situations where they can deduce part of a solution, and the types of deductions required are the main determiner of difficulty.

That said, Nikoli's approach is more extreme than necesary, and if done poorly it can lead to a puzzle type feeling boring if there aren't very many types of deductions to learn. An example of this is 0h h1, where the puzzles are more or less the same as the tutorial, except bigger.

For less standardized puzzles, like what you'd find in Mystery Hunt, motivating each step is even more important because that motivation is the only thing the solver has other than trying things more or less at random. Since trying things randomly isn't fun puzzle solving, puzzle writers should make puzzles that give the solvers direction.

Exactly how the direction is given is up to the author. One standby method is to have so-called "flavor text" that gives a hint (usually obliquely) about what sorts of things the solver should try doing. Some authors feel that this is an inelegant solution, and I'm inclined to agree. Ideally, the puzzle's mechanics themselves give direction.

For Mystery Hunt specifically, there's an answer extraction aspect to the puzzles, since every puzzle is supposed to give a word or phrase at the end. The answer extraction step serves to transform whatever data has been compiled for the puzzle into that word or phrase. A classic answer extraction step involves taking a sequence of numbers and translating them into letters by A=1, B=2, and so on.

There's a bunch of these extractions that aren't really motivated except by the fact that they are standard in puzzles. I'm personally of the opinion that this is suboptimal and that puzzle writers should strive to make their answer extractions natural even to solvers without knowledge of the standard methods, for example by making sure that the letters come out of the puzzle as letters, and not as numbers.

The puzzle steers the solver away from incorrect approaches.

Similar to the above point, the puzzle has responsibility to not only steer the solver toward the correct solution, but also to steer the solver away from wrong ones. Remember that a puzzle should be designed to be solved, and this is part of it. If a solver follows an incorrect approach that looks potentially correct for a long time, they won't feel accomplished when they learn the correct solution. Instead they'll feel cheated.

A big part of making a puzzle that steers the solver away from incorrect approaches is to ensure that there are no red herrings: aspects of the puzzle that actively make the solver believe that an incorrect idea is the intended route. Most red herrings are unintentional, but ideally you catch them before releasing the puzzle to the audience. That's one of the purposes of testsolving. If you can identify a common pattern among testsolvers that isn't pointing toward the correct solution, then there's probably something in the puzzle that's causing it.

Every piece of the puzzle serves a purpose.

This particular point is one that's more about my personal preference, and I know people who don't have this viewpoint. In some ways, this is another approach to the above two ideas. If a puzzle is made so that every piece has a purpose, then that means that a solver can look at what they haven't used for direction toward the solution. Similarly, because there aren't parts of the puzzle with no purpose, solvers won't be reading too deeply into them and finding red herrings.

All information given to the solver is fair game when trying to find the solution.

This idea is really a mindset of the author rather than a property of the puzzle itself. However, the mindset that the author has about what is "fair game" for the solver affects the way that they will write the puzzle. The solver should never need to worry about whether they are somehow "breaking the rules". So expect that a sufficiently sophisticated solver can and will do anything you can think of.

Are you giving them a program to play with? Expect them to try decompiling it and to try to determine its behavior from the code. If you want to hide code, put it on a server somewhere and only provide the solver a client. Even in that case, expect a solver to figure out the server interface and send requests much faster than they could do it by hand. If you're serving a pdf, expect that they might search for printable strings hidden in the file. The list goes on and on.

By adopting the mindset that the solver should be free to work with anything that is given to them, it means that the author thinks about all of that as parts of the puzzle itself, and then can think about whether those parts adhere to the same standards as the more obvious parts of the puzzle. Does having access to the code give away the answer? It's no coincidence that most Nikoli puzzles turn out to be NP-complete. They all have descriptions in terms of a quick way to determine whether a solution is valid, and then they choose rules so that it becomes difficult to systematically find a solution.

The puzzle breaks a rule.

Finally, we get to what separates great puzzles from merely good ones. A puzzle can be technically perfect: no red herrings, motivated solution, everything serves a purpose, and so on. However, if it isn't doing anything unique, then the solver isn't necessarily going to feel triumphant, but they might instead just dismiss the puzzle as more of the same old stuff. Just like each piece of a puzzle should have purpose, so should the puzzle itself, and breaking a rule is a great way to give a puzzle purpose.

So what do I mean by breaking a rule? Solvers come into solving a puzzle with a lot of rules in their mind. Some of those rules are rules enforced by the puzzle, but there's also going to be a lot of rules that only exist in the solver's mind. Breaking one of those rules leads the solver to learn more about the underlying mechanisms, which is especially useful when crafting a sequence of puzzles such as in Snakebird or The Witness.

Snakebird does an amazing job of breaking down rules that exist to the solver but not to the puzzle. The puzzles have been described as "literally impossible, until you solve them" for that reason. The puzzle is impossible when you have one of those nonexistent rules in your mind, but once you let it go, the solution becomes clear.

Those aren't the only rules worth breaking, however. I feel that the greatest puzzles are those that push the boundaries of what it means to be a puzzle. In other words, the puzzle breaks one of the rules of puzzle construction. For example, perhaps a puzzle looks incomplete, because you as the solver are actually missing the fact that the information from another puzzle is also relevant here. Or perhaps you can't extract an entire answer, because you're actually missing some information, and the idea is to instead use the completed answer to derive that missing information.

All of the ideas that I've written here are rules that could be worth breaking. It's important to realize, though, that rules exist for a reason. When you break a rule, it should be because you want the rule broken in order to enhance the solving experience. A great puzzle will break rules, but it will do so intentionally and with purpose.