Skip to main content

Procedural puzzles

For a non-combat game, puzzles play an important role. They are part of the resistance/reward cycle that keeps the game interesting.

If you only receive rewards all the time, then there's no reason to receive rewards. They are virtual items after all. They are only useful in helping you to progress through the game.

There needs to be some kind of resistance to your progress, or progress loses all meaning.

In a roguelike, we want the resistance to be procedurally generated. This usually means random monsters, traps and encounters. Locked doors and so on. Most roguelikes avoid procedurally generated puzzles, because they are harder to make than simple combat encounters.
Games that use puzzles often spend a lot of time to make the puzzles difficult and unique. But once you've mastered the puzzle, there's no fun to had in replaying it.

How can we make replayable puzzles for a non-combat roguelike?
Some time ago, I had a go at brainstorming some procedurally generated puzzles.

Some work better than others, and often, once you grasp the underlying concept, solving them becomes relatively easy, even with different starting conditions. Please forgive the crude graphics, the prototypes were not brought to completion as they were only intended as tests of the concepts.

Here are some of the prototypes I coded:

1. The door code puzzle.
In this puzzle there is a 4 digit number readout (I had a lot of fun programming an LED display). A voltage reader is attached, hooked up to the keypad. When the right numbers are set, then the voltage will drop to the green range. Changing each number gives feedback, the voltage reading goes up or down. The voltage is calculated by comparing the target number to the current number. The puzzle is pretty easy, though adding some random noise to the voltage reading can make it a little harder. The puzzle could be improved by giving each digit a different voltage multiplier, so feedback is not so clear. More digits could be used.

Difficulty: Low
Ease of generation: High
Replayability: High

2. The circuit puzzle.
There are three color coded +/- points fixed to the board. A number of colored pins can be dragged around. The wired can not cross. It's not a difficult puzzle, though it could be made harder by adding some obstacles, or limiting the length of the wires.
The board can have cut out sections where pins can't be placed.
Making this procedurally generated becomes harder if those aspects are changed.
Difficulty: Low-Medium
Ease of generation: Medium-High
Replayability: High

3. The fuse puzzle.
In this puzzle, there are a number of fuses in a stack. Clicking on a fuse removes it from the stack and shifts it to the top. For the demo, I didn't bother animating this, but it could have a short animation to show the fuses moving position. This can slow down the player's progress though, and might make it irritating.
Each fuse is assigned a value, and they are randomly sorted at the start. The color is assigned to match the value, scaled on an RGB spectrum:
To solve the puzzle, the player must sort the fuses in order.
To make it harder, some fuses could be missing, and need to be found in the game world. Also, the colors could be randomized or replaced with pseudo-nonsense markings. The player will have to experiment with different combinations and record how the output changes. More or less fuses in the stack can change the difficulty level.
Have to be careful of colorblindness and how it could affect players.
Difficulty: Low
Ease of generation: High
Replayability: Medium

4. The laser puzzle.
Although I had a lot of fun making this puzzle, it is the hardest to render in to a procedurally generated model. The puzzle consists of a number of lasers of different colors, walls to block their path, prisms and mirrors. There are also fiber optic cables. Some elements are fixed, some are freely rotatable. All lasers must combine their light on the central sensor to turn it white.
Making this procedurally generated would significantly reduce its difficulty for the player, though it could be made more interesting by requiring that components be found in the game world and dragged and dropped in to the puzzle. An unsolvable puzzle (with invalid starting configuration) could be overcome by spending resources.
Difficulty: High
Ease of generation: Low
Replayability: Medium

5. The resistance puzzle.
Each tile of this puzzle, except for the corner tiles, is rotatable. A simple version requires the player to rotate the sections to link up all four corners, like in the lights out puzzle below. In the advanced version, the player has to link the flow of electricity through the red, yellow and green nodes, until the voltage falls in to the required range.
Green +10v
Yellow -5v
Red -20v
The amounts can be randomized, to make it harder to guess by counting connections. In that case, the player has to try a lot of different combinations. Individual variations in each node could also occur (+/- 0.5v).

Difficulty can be increased by having a smaller or larger board with more connections.
Other elements could be added such as motors, chips and capacitors, which have different resistance levels. It could be necessary to connect all the components, while getting the resistance right.

It is possible for this puzzle to generate an invalid starting state, though very rare if the board is large enough. Maybe sections could be added or removed, using components from the game world, as in the laser puzzle above to avoid this outcome.
Difficulty: Medium-High
Ease of generation: Medium
Replayability: High

6. Lights out puzzle.
An easy puzzle once you know the right technique. In the more advanced form, the colors cycle from r>g>b>y by clicking, but all adjacent tiles also cycle. Trying to avoid contaminating already converted tiles in the key.

The basic form of the puzzle has just on/off lights.
Difficulty could be increased by adding components to the board which have to be lit up, or having points which must not be lit up to avoid failure. Accidentally connecting to the wrong terminal could cause a shock which boots the player from the minigame and resets the puzzle.
Difficulty: Low
Ease of generation: High
Replayability: High

One thing I'm not sure I really want to explore is reflexes or reactions puzzles. Games are usually divided in to those that require quick reactions and those which don't. Puzzle games are often played by older people or young kids who don't have lightning fast reflexes. Suddenly requiring them to use reactions can break the game for them. If you lack the skill to progress, then you have to give up. 

Giving some puzzles a timer could be a way of increasing their difficulty, but it feels a little cheap. Perhaps in game items could be used to help increase the available time. This would be a good addition to the metagame, allowing player progression to have an impact on the difficulty of puzzles.

Some other ideas for procedural puzzles include a spot-the-difference kind of puzzle, where a circuit board is incorrectly wired and you have a circuit diagram which shows the correct version, using a symbolic key or directions.

A pipes and plumbing style puzzle could also be used, in the case where we want to take a break from electronics.
The basic mechanics are similar, only the visual representation changes.

Other kinds of puzzles could relate to crafting. In this case, finding recipes and resources is the key to success. As an example of what that might look like, we can see the chemical puzzle from System Shock 2:
Chemicals could be combined to form compounds, which could be used in everything from agriculture to medicine. It could be fed in to 3d printers to produce items for use in the game. This part of the game would require scavenging and research. Chemicals could be extracted from ordinary household products, meaning that a trip to the city landfill could yield a lot of useful resources.
We could even look at biohacking and other ideas, to produce different kinds of plants, or vaccines against certain diseases. This part of the game design could benefit from input from a real scientist so that the recipes make sense.

I also have ideas for puzzle based dialogs and speech. Taking conversation to a symbolic level in order to make even communications in to a replayable, procedurally generated element. 
How would this work?
As an immigrant, when I first came to the country I spent a lot of time trying to find patterns in speech, to listen around the gaps that I couldn't understand and to try to identify key words. Reading a sign displaying information, I might understand only a few words, or simply the numbers and English letters. 
I could often only reply with a yes or no...
What if the text you are presented with in dialogs makes no sense? It consists of strange hieroglyphs or squiggles. The meaning of the words becomes unimportant, instead you have to find patterns. Puzzles could consist of trying to repeat patterns that are observed, or to order word groups in the way that the fuses in the game above are handled. We could find books in game which give us some reference:

32: ksdasd

Then we meet someone and they ask us:

sdadsdfh hgfh sds, 32? asddas, lgdfgd, sdss, ksdasd, llloops?

And we have to click the right word to get a positive reaction. In other cases, we might need to reorder words to get the outcome that we want. Clicking on a word in our speech bubble might delete it, reorder it or cycle it through a choice of variants.
Clicking on words in their speech bubble might add it to ours or cause them to rephrase their statements. There could be feedback between bubbles, so that as we modify our speech, theirs changes too. Like with the number hacking game above, the difference between the two bubbles shows how close we are to getting the correct answer.

The player might also have a note book, which can be used to collect words so that they can be dragged and dropped in to dialogs too:

fdsfd:sssdsd
wrewr:39
asdaswww:1980
sdasd:wtyytyy
hfgjhjg:KJH

hfgjhjg?

We can infer the answer we need, and we just need to drag and drop it from our notebook.

I like this idea, because it gives a feeling of what it means to be an outsider in society, trying to understand how things work. It also allows the game to be easily localized for players in different countries around the world.

Comments

Popular posts from this blog

Upstairs / Downstairs.

I've decided to make my prefabs multilevel. Later this should allow me to add pit traps and other great stuff. It also makes it easier to line up stairs so that you can exit them on the same co-ordinates where you entered them. The prefab editor is pretty much finished, it just needs some code for loading up prefabs from a saved dictionary, so that they can be checked or edited. The entries will need to be forwards compatible, so I'll be loading each tile and then translating the indexes to a new array, that way if I add extra indexes or extra info (like traps or puzzles) I'll be able to update existing prefabs to work with the new standard. Click for a video.

Automating Level imports from Blender to Godot

  Recently I've been making some levels in Blender an importing them into Godot. There are only about 7 or 8 shaders for each level, not counting dynamic objects which will be added later. But to improve rendering performance, it can be a good idea to split the meshes up into sections. At that point you might be faced with a list like this: Or it might be even more chaotic, if you didn't use simple names for the objects in your level. So it can take a long time to sort out all the meshes, make them unique and add textures and so on. Blender imports with simple Blender textures, or with placeholder materials. This is sometimes OK, but if your Godot shaders are very different to those used by Blender, it means applying new materials to every mesh object in the level when you import the scene. I found that during the design process, I was importing and readying a level several times before I was happy with the final layout. So at first I was wasting a lot of time. In Blender, I us

Advice needed on tilesets...

I need some advice on which is the best way to handle building the dungeon. Right now I'm using prefabs for my dungeon, they have a north south east and west section for each "room": The basic tileset. This has several advantages, and also several disadvantages. Firstly I can have curved rooms, I can have tunnels and other interesting shapes. The tilesets can look quite nice with a little work. On the other hand I can't easily get the navigation data before building the map and once the map has been built I can't make changes to the layout, like having active pit traps or believable secret doors. Although the rooms are interesting, they are quite repetitive, and it takes a lot of effort to make even a few different variations. Also rooms are constrained to one size. A newer version of the tileset with a lot of variant parts for making more interesting rooms. To create a tile set is a real headache too. Planning how to lay out the UVs, trying to cra