Thursday, 9 March 2023

Mathematical Puzzles in Fantasy Games

Mathematical Puzzles in Fantasy Games

Jonathan R. Partington

(Based on a Trinity Mathematical Society talk given on November 10th 1986)

Acheton

The connection between Mathematical puzzles and adventure- like settings is an old one: it predates the advent of computers and Adventure Games, as well as that of role-playing games.

For example H.E. Dudeney, in his 'Canterbury Puzzles' (about 1903) has a chapter relating 'The strange escape of the king's jester', who has to solve several mathematical puzzles, including a maze and the guessing of a safe's combination, on his way to freedom. The jester was presumably locked up for being a mathematician.

There are many much older examples, but we shall be interested here in more modern puzzles with a non-trivial mathematical content. I know of two specifically mathematical adventures, Peter Killworth's Giantkiller, and the American game 'L'. However mathematical puzzles occur in many other games.

Let's begin with a puzzle from Graph Theory. You are exploring a network of rooms that looks like this:

          O---O
          |  /|
          | / |
          |/  |
     -->--O---O
          |\ /|
          | \ |
            /
          |/ \|
          O---O-->--
          |  /|
          | / |
          |/  |
          O---O

You enter and leave the network as shown by the arrows. In addition, each room contains a single coin, so that there are eight altogether, and, by a strange coincidence, you need exactly eight coins to pay your fare home once you have got through the maze. Now comes the tricky part: these eight caves have a property shared by some old college rooms - the roof collapses as soon as you leave them.

Thus, reducing the problem to its mathematical basis, what you have to do is to find a path through the network that allows you to visit each node exactly once: A Hamiltonian Path, named after the Irish mathematician Hamilton. It is not hard to verify that there is exactly one way through, and so the puzzle has a unique solution. One could of course construct harder variants of this puzzle, in which it was impossible to visit all rooms, and one had to visit as many as possible: and so on.

In the next puzzle, another graph-theoretic problem arises.

          O---O
          |   |
          |   |
      O---O---O---O
      |   |   |   |
      |  A|   |   |
      O---O---O---O---O
         /|\  |   |   |
          |   |   |   |
      O---O---O---O---O
      |   |   |   |
      |   |   |   |
      O---O---O---O
          |   |
          |   |
          O---O

The above shows another network of paths connecting larger areas, and one enters (from the southwest) at the point A. Life is not simple, however, and the player is in fact being pursued by a Tyrannosaurus Rex; it is close behind him, and has the property that its stampeding causes avalanches to block each path behind it. The player is safe if he can leave A by the south-east, but he cannot do this immediately because of a flock of 32 pterodactyls that is taking off in perfect formation from the place he is aiming for.

It follows that what one has to do in this case is to find a path along the network that starts at A, takes in all 32 edges exactly once, and finishes up at A (just as the last bird is flying away).

This is an example of an Eulerian path. Originally Euler was asked by his pub-crawling friends whether it was possible to walk round Königsberg, whose network of pubs and bridges is shown below, in such a way as to take in every bridge exactly once.

        O----
       / \   \
       \ /    |
        O-----O
       / \    |
       \ /   /
        O----

In this case the problem is insoluble. Consider a node on one's route: if it is not the starting or finishing point then an even number of edges must radiate from it (as every time one arrives, one leaves by a different road). In this case however, all four nodes have an odd number of roads leading out, which makes the task impossible.

Another manifestation of the Eulerian path occurs in Giantkiller, where the player is forced to run along the strands of the giant's teatowel (which keep breaking), and must keep going long enough to avoid being dropped into a fire.

Mazes themselves are a fine source of mathematical puzzles. Sometimes there are straightforward ones that can be solved by mapping, though this can be made difficult, for example by having a rotating maze whose directions constantly change. In other examples, one is given a clue to the route, and must go the correct way or meet a horrible fate (often a minotaur!)

In 'Exile', for example, there is a tavern, whose name can on occasion be the 'Sun Seed', the 'Nude Nun', or even the 'Used Ewe' (a farmers' pub). Once in the tavern, one has to evade the press gang. This involves a chase through the cellars, where the directions S-U-N-S-E-E-D are required. (In 'Brand X' the way out of the Garden of EDEN is 'spelled out for you' by the serpent!)

In a Dungeons and Dragons game, the players once came across the following doggerel:

   'Go deeper in, though ways be Dull:
   Follow the trail, aye to the Full!
   All foes disperse, as scraps of Fluff,
   Should you win through this blind man's Buff.'

It was necessary for them to interpret the last word of each line and go Down-Up-Left-Left etc, in order to get through the maze. Every wrong step brought them a monster to fight.

Another way of concealing directions is by anagram clues, so that North, South, East, West become Thorn, Shout, Seat and Stew.

Back to puzzles with a more serious mathematical content. Consider the following network of roads, where the numbers indicate how many hours is takes to get from one junction to the next.

                       /
                      /
   O--1--O--4--O--1--O
   |     |     |     |
   4     1     1     2
   |     |     |     |
   O--5--O--3--O--1--O
   |     |     |     |
   3     2     3     2
   |     |     |     |
   O--6--O--1--O--2--O
  /
 /
Here one starts at the southwest and wishes to get to a village at the northeast by the shortest possible route. (Some ways take longer than others because they are busy widening the road, or, if it is like Cambridge, narrowing it.) If one gets through in 12 hours, then one is in time to save the city from destruction by a giant: if not then the mangled villagers greet you with cries of "Oh great hero, if only could could have reached here sooner...".

This puzzle can be solved by a process known as Dynamic Programming, and the mathematical theory is well-known.

Another, more fantastic, puzzle is the ice-rink, which is square and with 25 letters painted on it in a five-by-five grid, e.g.

  Q  W  E  R  T
  U  I  O  P  A
  S  D  F  G  H
  J  K  L  Z  X
  C  V  B  N  M

so that there is one letter missing. The player now has the opportunity to skate along this rink, but only in 8 successive straight line segments, before the ice melts and he finds himself in an area strangely resembling Trinity Great Court. This has 26 staircases leading off it, lettered A to Z. Twenty-five of them have trolls living on them, the twenty- sixth has a tutor. Each is about to have dinner, but the trolls will eat him whereas the tutor probably won't. Thus, since the safe staircase corresponds to the missing letter (Y, in our example), the player has to have covered all 25 points in 8 successive lines (an old problem going back to Dudeney, and maybe beyond).

Another problem of a different type altogether comes from the game Exile, and is called the Plague Village. Here the problems involved are logical ones, in a style much used by Raymond Smullyan (see for example, his book called "What is the name of this book?")

When the adventurer reaches the plague village, he finds a parchment, which bears (in faded letters) the message:

"Beware of PLAGUE - its effects are slow but fatal. The village is dead. The alleyways are dangerous and mostly infected. We, the villagers, kept exactly one route to the graveyard free of infection. Alas, many people put up signs, and in the madness of the plague they often contradicted each other. God be with you, stranger!"

Thus, the player has to find the safe route to the graveyard or die a horrible death. At the first junction he sees three signs, which read:

  NW: Keep away! Plague!
  N:  Keep away! Plague!
  NE: At most one of these three signs is true.

(Clearly the village mathematician, or possibly the village idiot, wrote the sign on the north-east route!) Such a problem is easily solved, in fact by symmetry only the NE route could be the unique safe way. One further example:

  SW: The sign on the west alley is true.
  W:  If the southwest sign is true, so is the northwest sign.
  NW: This way is safe.

I leave this one as an exercise. Once the player reaches the graveyard safely, he finds a thighbone, which is then of some (non-mathematical) use to him.

One can even base adventure-type puzzles on Group Theory. Consider, for example the famous 'Fifteen puzzle' of Sam Loyd.

     +----+----+----+----+
     |    |    |    |    |
     |  1 |  2 |  3 |  4 |
     +----+----+----+----+
     |    |    |    |    |
     |  5 |  6 |  7 |  8 |
     +----+----+----+----+
     |    |    |    |    |
     |  9 | 10 | 11 | 12 |
     +----+----+----+----+
     |    |    |    |    |
     | 13 | 15 | 14 |    |
     +----+----+----+----+

Here one has fifteen numbered blocks which can be slided in their four-by-four box, either north-south or east-west, moving one into the empty space at each stage. The challenge (which was a sort of Rubik's cube of the early 20th century) is to exchange 14 and 15. However one can show by group theory that only half the positions are possible, and that the problem as posed is insoluble. To make that seem plausible, consider the 'Three puzzle', which I haven't bothered patenting...

     +----+----+
     |    |    |
     |  1 |  2 |
     +----+----+
     |    |    |
     |  3 |    |
     +----+----+

Here it is obvious that the only re-arrangements possible are cyclic rotations of the pieces.

The idea occurs in a more complicated form in the Relic puzzle in Fyleet.

     O---------O
     |        /|
     |       / |
     |   -O-   |
     | /       |
     |/        |
     O---------O

Here there are four sacred relics which have to be put into the correct rooms, and the supernatural forces are such that no two relics can occupy the same room simultaneously. After a bit of experimenting (or calculation) it turns out that the problem cannot be solved, as you start with one of the set of positions inequivalent to the desired one. However... one of the relics is the Sacred Sunglasses of St Tropez, and wearing them the player is able to see a secret door (linking the middle room with the bottom right room). Using this extra connection, one can now get all possible permutations, and the problem is soluble.

This is a puzzle that requires several stages of solution. Firstly, to work out what one must do; secondly to see that it is impossible; thirdly to find the trick!

Another group-theoretic puzzle occurs in 'L', where one has permute a set of lights by means of switches. For example, one may start with

         O        O        O        O
        red     blue    yellow    green

and have to obtain some other ordering using two switches. One switch swaps the colours of the first two, the second cycles the colours. Again it can be shown by elementary Group Theory that one can obtain any desired ordering.

One fruitful source of puzzles, with a certain mathematical content, is that of Ciphers. Should the adventurer see written on a wall the message

UIF QBTTXPSE JT IPSTF

he or she will guess it to be an encrypted message. If, further, the message is known to be something about passwords (someone somewhere asks you for a password, say) then it is easy to spot that all we have done above is shifted each letter on one in the alphabet, and 'The password is Horse'.

Elsewhere one may find the word TUBS written up; if one says it, maybe the roof falls in - the correct thing to say was STAR: same code! In fact not many English words do give real words when shifted: ANTS becomes BOUT, ADDS becomes BEET, and so on. (I am grateful to Mr Matthew Richards, T.M.S. Dogsbody, for telling me about SHEER and TIFFS, now the longest example I know.)

To decipher the average coded message one tends to need at least 60 characters of text, more if the letter frequencies are unusual (e.g. no E!) (It used to be a habit among Trinity mathematicians to confuse the porters by sending each other coded postcards from wherever they happened to be - Russia being the most exotic.) Thus if one has fewer letters, one needs some context information.

In the game Avon, based on Shakespeare, there is an area called Illyria Court, in which live (Sir Andrew) Aguecheek, Fabian, Orsino, Olivia and Malvolio. Elsewhere, one encounters Othello, who gives one a piece of paper in 'Moor's Code' (such bad puns are common), which is supposed to tell you which of the residents to visit. Thus the paper says one of NOSEBLEED, OVERSEAS, ASTHMA, TEABAG and FUNGUS. Assuming a simple substitution cipher, one can easily verify that only one resident's name can be referred to by any given codeword. Thus, e.g., FUNGUS refers to Fabian (6-letter word, second and fifth letters equal).

These patterns have interested me for some time, especially since I learned that my own name, Partington, has the same pattern as Budgerigar!

One can also hide numbers, e.g. by alphametic-type puzzles. In one Dungeons and Dragons game the players came across an addition sum written as

          ENTER
          ENTER
          ENTER
         ------
         HEROES

together with a magical artefact bearing a dial and a headpiece (in fact remarkably similar to a modern telephone!) It was necessary to solve the puzzle and dial the number corresponding to HEROES to proceed further.

The binary system is another source of good puzzles. One can get away from slot machines taking coins of values 1, 2, 4, 8, ... and construct more elaborate problems. For example, in Crobe, one finds a sword embedded in an anvil near which someone has written the legend "He who draws this sword from the anvil is the rightful Head of DAMTP" (well, in the original it was something else, but this is an Applied Maths puzzle). Various switches nearby have to be thrown to produce a binary representation of some code-number (provided). This turns off an electromagnet in the anvil and allows one to extract the sword, then going forth to multiply (or whatever they do in DAMTP).

In Fyleet, the ternary system is used for the 'hippogriff rides' puzzle. One's coins this time come in the values 1, 3, 9, 27, ... but the price for a ride can be any integral amount. This requires negative money, and nearby one goes through a matter converter, so that coins take negative values. Thus a fare of 20 groats can be paid (uniquely) as 27 + (-9) + 3 + (-1)!

Clearly many Adventure puzzles can be obtained by adapting classical puzzles from the Dudeney era or beyond. Consider the Wolf-Goat-Cabbage puzzle: here one has to cross a stream in a boat, and transport (one at a time) a wolf, a goat and a cabbage. However one cannot leave the wolf and the goat together unattended (at least it does the goat no good); similarly the goat will eat the cabbage if left alone with it. The solution here is to take the goat across first (since it cannot be left with anything else) and continue from there.

Thus, in Fyleet, one sees a poster, which reads:

LOST - ONE WOLF, ONE GOAT, AND ONE CABBAGE. REWARD OFFERED.

Here we have an almost straightforward adaptation of the puzzle (one twist being that the wolf bites you en route and you catch lycanthropy - become a werewolf - unless a remedy is found!)

In 'L', a tree-planting puzzle is borrowed directly. To assist the gardener one has to plant 9 trees in 10 rows of 3: the solution is essentially:

     O   O   O
       O O O
     O   O   O

Similarly, Acheton borrows the Tower of Hanoi puzzle - to transfer a series of flat disc-shaped rocks which are piled up in one room, to another room, without ever putting a larger rock on a smaller. Underneath the largest rock there is secret tunnel...

Then again, in Crobe there is a version of Dudeney's safe puzzle (in the original the secret word was PYX - here a more common word is intended).

The safe door bears 4 dials, each with letters round it thus:

                             B
                            ---
                          Y/   \G
                          X|   |H
                          N\   /K
                            ---
                             M

The man who writes poems on walls has been round again, and his effort this time is

   The safe door be broken
   By word sung or spoken.

In fact one (fairly obvious) English word can be made using just 4 letters, each one of the ones on the dials.

Finally, a puzzle that is mathematically quite intricate - a scheduling problem from Sangraal. This occurs in the endgame, when the Sangraal (Holy Grail) is almost won. You arrive at the castle where the Foul Fiend has imprisoned 8 knights. These are as follows:

Agravain - lightly bound - badly wounded;
Bors - lightly bound - scratched;
Caradoc - bound a bit more - badly wounded;
Dagonet - bound as C - scratched;
Ector - bound and gagged - somewhat wounded;
Feirefiz - in chains - badly wounded;
Gareth - in chains and gagged - somewhat wounded;
Harry - bound really tight in chains (poor chap) - scratched.

Here the state of binding means that it will take 1, 1, 2, 2, 3, 4, 5 and 6 minutes (respectively) to free them: a freed knight then goes away to wash and recover himself physically in time for the Sangraal's arrival. The time he takes for this second stage is 5, 10 or 15 minutes, according to injury. In twenty minutes' time the sun will set and the Sangraal will arrive. How many knights can you bring? We see, for example that if you want F, you must free him almost at once, as he can only be ready in 19 minutes at the earliest. Freeing Harry, though it takes 6 minutes, is not urgent, as he only needs to be freed by the 15th minute. This sort of puzzle has standard algorithms for solving it, but it is at least a bit more interesting than the average optimization exercise!

So what next? Adventure puzzles based on Chess, on the notorious game Neutron, on Complex Variable Theory? These are left as exercises for the reader!

Last updated on December 7th 2002 by Jonathan Partington

Designing Adventure Puzzles

Designing Adventure Puzzles

Jonathan R. Partington

(Based on a Connote8 talk given on July 3rd 1987)

dragon hatching

It's probably best to say first what this talk is NOT about. I receive quite a lot of feedback from people who have played Adventures I have written, and the following is a typical message:

"Thanks for your hints in regard to Fyleet. I've made considerable progress since dealing with the wizard and am now up to around 300/600 points. I've still had no luck getting the phoenix out of its present state. I did manage to get Bacchus to do something useful for me; however, this raises the question as to whether the barrel is useful or can be ignored. Also, is the symbol of Hurgenpor (in the tunnel after riding the Hippogriff) useful at all? I'm currently trying to deal with the Dwarf and the A-Z exit. Still unsolved are how to pass without a trace and float like a feather. Am I correct in assuming that it really isn't necessary to wish at all? It seems that by wishing you're forced to lose one treasure."

Well I don't propose to answer any of those questions here, more to give some ideas of how one constructs adventure puzzles. There is a classic joke that seems appropriate here:

Q: How many adventure players does it take to change a lightbulb?

A: One to type BREAK BULB, another to try EAT BULB in the wrong room, another to try WAVE BULB, ...

The moral being that whatever you do and however obvious you think a puzzle is, there will always be some contingency you don't allow for, and someone who will try something you didn't think anyone would try.

Adventures come in a variety of styles, with different aims and plots (sometimes rather thin). A few typical 'player goals' are as follows:

Collect loot (Colossal Cave, Zork, Acheton, Murdac, Philosopher's Quest, Quondam, ...);

Win back your kingdom (Hamil);

Impress someone enough so that they will help you fight some adversary (Fyleet, Crobe);

Show virtue enough to win the Holy Grail (Sangraal);

Escape from prison (Xandos);

Regain your sanity and then fulfil some mission (Xeno);

Kill a mighty wizard (Parc);

Kill a giant (Giantkiller!);

Get off a planet alive (Countdown to Doom);

Get out of the world you're in (Avon);

and so on. Let's have an example -- the start of a typical adventure game (Crobe).

                            SEA / BEACH
             O----------------------O----------------O
             |                       CLIFFS           \
             |
          O--O--O flour             O----------------O lemming
          | / \ |                   | mystic
  zombie  O     O TOWN              | pole
          | \ / |                   | flame
          O--O--O accordion         |
             |                      |
   fish O----O----------------------O----O princess, throne
   RIVER            ROAD        |
                                |
                                O witch

                   THE START OF AN ADVENTURE

This is a game you probably haven't come across, called Crobe. The hero has been sent to deal with some evil being called Karg who has laid the town of Crobe to waste and is now believed to be in hiding somewhere in the cliffs nearby with an army of trolls. Your mission is to dispose of him.

Well I don't intend to explain how you do this, but, for illustration, let us look at some of the 'above ground' features.

Over to the west we have the ruined town of Crobe, and its sea-front, with the tide in. Objects which may or may not be of use include a wandering zombie, a bag of flour, and an accordion. Also a dead fish washed up on a river bank. Over to the east, outside the town, there is more to see: a witch, who demands that you discuss some interesting topic with her (though initially nothing seems to interest her); a princess on a golden throne; a mystic sitting on a pole near a fire; and a statue of "The Unknown Lemming", appropriately placed at the cliff edge.

Experiment suggests that eating the fish is not a good idea, as it needs cooking. However, when you cook the fish on the sacred fire, the mystic grabs it and runs off, complaining that he hasn't eaten for weeks and that your action in cooking fish nearby is more than his flesh and blood can stand. So this leaves you with a pole, by the cliff edge.

Kissing the princess is obvious enough: she turns into a frog, allowing you to sit down on the throne. In best Canute style, this causes the waves to recede and the beach to appear. The frog itself has another use later, but at this stage it just makes strange croaks of "WEEBLE", "BARGLE" etc. at you.

Proceeding along the beach you find a cave entrance, but since there is a cyclops standing in it, it is rash to go further. Instead you go back and and push the pole over the cliff (so that he comes out to investigate) and finally push the lemming over (crushing him). In fact the items you haven't yet used do come in useful later, although you have to explore a but further to see how they fit into the game. That's probably a fairly hard opening for an adventure.

Let me give some examples of what I consider to be bad puzzles -- where the player feels dissatisfied, even when he's solved them (I'm not claiming that I can always do better!) They all come from games which otherwise are good in many respects.

Waving the rod (a magic wand) in Colossal Cave: first of all you are supposed to wave it in places where it is not at all obvious that you need to do anything at all (e.g. at a fissure, where a crystal bridge appears); secondly there are places where you need to wave it twice before anything happens. This seems a bit unfair. The player ends up trying to wave the rod everywhere he goes.

The magazines in Colossal Cave. You score a point for leaving them somewhere. It is not at all clear why!

In Zork, there is a curtain of fire. Saying "Go North" (or whatever direction it is) doesn't let you pass through. "Walk through curtain" is required. No one knows why, and most people have to be told the precise wording.

Again in Zork there's a puzzle founded on Baseball. Not much point if you don't know the game!

In Hezarin, there is a place where you see the illuminated sign "G - 1 - 2 - 3". The answer is "Enter lift". All right, there is a puzzle there -- to recognise that it's a lift. But I would prefer "Call lift" as the solution and would have wanted to allow "Press button" or whatever as well (assuming that there is a lift button).

In "L", a Mathematical adventure, there is an elliptical billiard table. The ball starts at one focus and you find that, whatever angle you hit it in, it goes into a pocket at the other focus. All very interesting, but totally useless: there isn't a puzzle there at all, it's merely rather irritating local colour -- irritating because the player looks for a problem that isn't there!

How much magic do you put into an Adventure? Well, there are perfectly good adventures (e.g. Xenophobia, which is set in London) in which no magic is involved. At the other extreme you have adventures with magic words chalked up on every wall, and the poor player going all the way round the game trying to find out where exactly the word "BZZZT" does something, only to discover that you have to be in the Great Hall and holding both the parrot and the teapot, but having already eaten the melon and thrown the pig at the duchess. I exaggerate, but you see what I'm objecting to: purposeless magic. Magical artefacts that suggest what they might be useful for (e.g. mushrooms that when eaten make you strong, causing you to wonder where strength might be useful) are much better than objects with irrelevant magical side-effects.

I'd like to say something here about the conventions of Adventure games, and how they can be made less hackneyed. Firstly, Mazes. Many adventures have mazes of some sort in them. They vary from the elementary (drop objects in order to make the rooms look more different from each other) to more subtle variants.

In Zork, for example, dropping objects is partially thwarted by a thief, who wanders round and picks them up again ("My, someone's left a fine sword here!") In the Hamil maze, life is made harder for the player by the fact that every time he leaves a room, the ceiling collapses, and so he can't visit any room more than once (and needs to visit all the rooms in the maze since they all contain something). In Acheton there are the Ice Mazes, where the ice is always about to melt: a thermometer is used to identify the safe way through.

Sangraal has a rotating maze, where the directions keep changing. Fyleet has a greatly simplified version of the Fifteen Puzzle, where you have to manoeuvre objects about that cannot be put two in the same room. Murdac has a haunted house, where a poltergeist is throwing objects at the player, who has to deduce where the ghost is and avoid it. Philosopher's Quest has the notorious Garden of Eden, where the serpent very persuasively offers the player all sorts of rewards if he will eat the apple on the tree. Finally the snake says "Do I have to spell it out for you? You're in EDEN!" The directions E-D-E-N may be found helpful here...

Another convention is the Rusty Rod (sometimes with a star on the end). In various games that becomes a magic wand, a morning star (the weapon), a crowbar, an electrical conductor, ...

How much combat do you put in an Adventure game? Colossal Cave has the dwarves (and the player has a nonzero probability of being killed whatever he does). In Acheton there is a little green-eyed idol (cf. the famous poem about a one-eyed yellow idol to the north of Khatmandu), which when robbed of its eye comes back for vengeance: and if the player is unlucky will get it! MUD of course contains large elements of combat, as does the original Fantasy game. Mystic Wood and Sorcerer's Cave have been computerized, and make amusing "Hack-and-Slash" games.

Combat systems can be rudimentary or very sophisticated indeed. You can have a simple system where the player has a fixed probability of winning a battle, right up to a full simulation of the system in some Role Playing Game like Dungeons and Dragons or Runequest.

So where does one get the ideas for puzzles? The answer is, almost anywhere, as I'll indicate.

One useful source is literature. One can pinch, I mean adapt, all manner of classical themes. The Sword in the Stone has been used in numerous games (in Colossal Cave you need the strength to pull it out, in Quondam it breaks and needs repairing, in Crobe it's held in an anvil by electromagnetism and you need to break the circuit). The Ancient Mariner turns up in Philosopher's Quest, and you end up with an albatross round your neck that needs removing. The Hunting of the Snark provides a puzzle in Hamil, the Phoenix legend to Fyleet.

I once saw an opera (a Russian one, I think) where someone filled a golden bowl with water and saw a vision. The idea was used in Murdac. Moses and the Ten Commandments (or, more precisely, the 11th) have a role to play in Sangraal, as do Edgar Allan Poe's Raven (Nevermore) and Shelley's Ozymandias!

Given an item in a game, one often devises puzzles which exploit its various possible uses. A witch's broom can also be used for sweeping the floor to expose a trapdoor. A duster can be a bandage, a cloth, etc. In Fyleet there is a prayer mat which, when used appropriately, causes a mighty wind to arise. This can blow things out of trees, disperse fog, and so on.

Thematic puzzles are enjoyable, and you get several at once that way. Sangraal has two such. First there is a 'Seven Deadly Sins' area, where the object is to commit each of the sins in turn -- being slothful, being gluttonous, and so on (I had trouble implementing Lust in a tasteful way). It also has a Noah's Ark puzzle, where you have to find animals to take to Noah: sloths in trees that need waking, wolves that are too fierce to handle, tied up emus that it seems impossible to free, and others!

Some puzzles depend crucially on timing. Acheton has several such: a giant who stomps around in a regular path (& will crush you if are in the wrong area at the wrong time); the mummy Yelka Oekim who must equally be evaded (the solutions are different!); a notorious snake maze which you can explore while the snakes are asleep, but which you must activate later, risking attack from the snakes, in order to liberate the treasure. Another example is Crobe's ship wrecking: you have to let some pirates take over a ship, then show a false light to guide them onto the rocks!

Some puzzles come naturally and the adventure writer also has to struggle to find a solution. For example, in the barn in Fyleet, an animated white sheet descends on you and smothers you: it was my wife's idea that the player should wear a spiky Teutonic helmet to protect himself. Elsewhere I needed a one-way exit to avoid the player returning the way he'd been. The barn naturally suggested a bale of hay, down onto which the player could jump.

Finally, there are plenty of conventional puzzles which can be put into Adventure settings. A few examples follow.

 ENTER
 ENTER
 ENTER
======
HEROES

The above is an alphametic. The numbers solving it can give a combination used elsewhere.

UIF QBTTXPSE JT IPSTF. A cryptogram (suitably arranged in a crypt in Hamil).

Then there are steals from Dudeney and other famous puzzlists: "Lost - one wolf, one goat, one cabbage". The old puzzle about transporting wolf, goat and cabbage without leaving the wolf alone with the goat, or the goat with the cabbage.

Logic puzzles:

 NW exit: If this is the safe exit, then N is False.
 N exit: If this is the safe exit, then NE is False.
 NE exit: If this is the safe exit, then NW is True.

Puzzles based on Binary and Ternary systems ("Hippogriff rides 29 groats -- please insert exact fare").

In fact almost anything can be fitted into an Adventure somewhere. As an extreme example, Sangraal has a "Klingsor's Tower" puzzle, where the evil wizard Klingsor challenges the player to a wide range of contests: solving riddles, completing poems, simple games, and various miscellaneous puzzles.

In summary, it's very easy to design Adventure puzzles. I've never been able to solve them, though.

Last updated on December 7th 2002 by Jonathan Partington

Computers and Language

Computers and Language

Computers and Language

Jonathan R. Partington

(Two articles printed in the magazine Logophile in the late 1970s)

It is my intention to expand and update these some time (they are over 40 years old and a lot has happened since!)

EDSAC
Part 1

 Do not puncture a loon
 Oh mouse-like mattress !
 The spleen shrieks.

 Our auctioneers rotate
 Just before the banshee strangles a turbot.
 The butterflies shout "Wow !"
 Terribly.

 False goats are vicious
 Though not really radioactive.
 My bugle-player stupidly
 Garottes the Viking warrior.

 Surely unsound gorillas read newspapers ?
 A drenched turbot shrieks.
 My cliche-ridden banshee wobbles indefinitely
 Disguised as a lumpy passer-by.

 Never consult a weasel
 Oh ye auctioneers !
 Surely the anglers plague rubber ducks ?

 Our turbot catches a train.
 Loofahs are plump.
 Oysters are bouncy.

 The scarlet policeman nocturnally pummels wicket-keepers.
The above is not an outburst from some rather avant-garde poet, but was written by an I.B.M. computer which I programmed in the Fortran language. The machine was given a list of words, classified into parts of speech, together with some grammatical rules enabling it to compose a random sequence of sentences. I rejected the more clumsy sentences by hand and arranged the remainder as above for convenient reading. Clearly there is very little artistic merit (or, indeed, meaning) in the poem, but the sentences do have some originality.

In amusing myself with computers and words, I have found that it is difficult to produce verse which simultaneously rhymes, scans, and is grammatically correct, without making the poetry seem stereotyped. One curious way of avoiding this difficulty is to tell the computer to invent its own words, so that the sounds of the poetry are more important than the sense. One method of creating new words from old is the "triples" algorithm - the computer is given a list of real words as input and programmed to create new words (i.e. random sequences of letters and spaces) such that any sequence of three consecutive letters can occur in a new word only if it occurred somewhere in the original text.

For example, given the real words LOGIC, POGO, GOPHER and XYLOPHAGY, the nonsense word LOGOPHAGY (Eating one's words?) might be produced, since the triples LOG, OGO, GOP, OPH etc. all occur in the original text. So also might the words POGIC and XYLOGOPHER which I will not attempt to define. A slight technical modification enables words to begin and end plausibly.

It is then possible to devise rules for calculating the number of syllables in a word, and so the computer can be made to fit words into a nonsense poem which rhymes and scans reasonably well. For example, given a French text, the computer was able to produce a poem beginning:

 Nonon lait etalletut
 Laitte eforte fans
 Vile ceravait non une fut
 Ent pelevientraimans.

The flavour of a foreign language is usually preserved, as in the above example. Similarly, "Zusrer beweinem wirkauckt" seems vaguely German and "Ahova czabanyak lasszon" is plausible Hungarian!

In general, however, some human intervention is desirable and this may even consist of writing one's own poem using only computer-generated words. The following is an abridged version of a poem I produced in this way:

XYLOTURBOT (Ode to a wooden fish)

 Equitome cuperti jugum
 Gassowary jugulard
 Gnodulexy opule aublum
 Jugulegus ine mactard

 Lincubut strophlepsy cangoose
 Pangory panthrodulam
 Mango gizzarcurgeist vapoose
 Oozelumny tracer lam

 Splegitaceous ergeon poozle
 Repumandon pangle mose
 Ophalungous nox arcoozle
 Olophid propodinose

 Wombiquangle nomet slotule
 Batorpoic quagus curge
 Mangonimbo lycat pugule
 Uble bergle tragmine wurge

 Gnomelligo xystergeous pan
 Volturgity olobule man.

It should not be difficult to guess several of the words used as data; some of them appeared in the poem we began with and others were chosen for their unusual appearance. If the reader feels like singing some of the poem, he will find that "Clementine" and Beethoven's setting of Schiller's Ode to Joy are both suitable tunes.

In conclusion, I think we are still a long way from a state like that in Stanislaw Lem's "The Cyberiad", where an electronic bard caused chaos by producing vast quantities of immortal verse. It is quite easy to make a computer produce enormous quantities of poetry, but much harder to decide which is the best without human intervention.

Part 2

When I last wrote on this subject for Logophile, I remarked that it seemed difficult to induce a computer to produce poetry that simultaneously rhymed, scanned and was grammatically correct, without making the verse seem stereotyped. However it is certainly possible for a machine to write poems with a definite structure, although the end-product commonly resembles (and is) nonsense-verse. The following computer-produced sonnet is typical.

 How can the purple yeti be so red,
 Or chestnuts, like a widgeon, calmly groan?
 No sheep is quite as crooked as a bed,
 Though chickens ever try to hide a bone.
 I grieve that greasy turnips slowly march:
 Indeed, inflated is the icy pig:
 For as the alligator strikes the larch,
 So sighs the grazing goldfish for a wig.
 Oh, has the pilchard argued with a top?
 Say never that the parsnip is too weird!
 I tell thee that a wolf-man will not hop
 And no man ever praised the convex beard.
 Effulgent is the day when bishops turn:
 So let not then the doctor wake the urn!

To produce this poem, the computer was supplied with the skeleton of a sonnet together with a large list of words, classified by parts of speech and numbers of syllables. The program then substitutes in words where appropriate, so that, for example, the line "Effulgent is the day when bishops turn" became "Demented is the day when magpies growl" in a later run. The rhyming here was accomplished in the simplest way possible, by ending each line with a monosyllable and making selections from a list of pairs of rhyming words.

It is still interesting to allow a computer to make up its own words, stringing together fragments of real words in some way. If the source words are thematically related, a poem written with the newly-generated words often has a remarkably uniform style, as illustrated by the following exercise in pessimism.

 MOANCHOLY

 How deprespon mismal moanic
 Nondent failur borment groanic

 Of bormentious dendepressive
 Gnastly grum doloom buressive

 Woe desponent moanite purglous
 An howlinguish nondle burglous

 How deprespon mismal moanic
 Nondent failur borment groanic!

Leaving the subject of poetry, I would now like to suggest some further applications of the buzz-word generator, which has already been much discussed in earlier issues of Logophile. Strictly speaking, these applications do not require a computer, as the work involved is not great, but, apart from its natural associations with technology, the buzz-word generator does require random numbers, which a machine can produce very rapidly. The following is an example of a proverb generator: by picking one phrase from each of the two columns below, a plausible aphorism is often produced.

 Uneasy lies the head that      wears a crown.
 An apple a day                 keeps the doctor away.
 A rolling stone                gathers no moss.
 The early bird                 catches the worm.
 The road to Hell               is paved with good intentions.
 It's an ill wind that          blows nobody any good.
 A watched pot                  never boils.
 It's a long lane that          has no turning.
 A stitch in time               saves nine.
 A bird in the hand             is worth two in the bush.
 Half a loaf                    is better than no bread.
 Pride                          goes before a fall.
 Man                            cannot live by bread alone.
 One swallow                    doesn't make a summer.
 Absence                        makes the heart grow fonder.
 He who laughs last,            laughs longest.
 A cat                          may look at a king.
 It's love, it's love that      makes the world go round.
 Brevity                        is the soul of wit.
 Beauty                         is in the eye of the beholder.

For example, "Absence keeps the doctor away" and "It's a long lane that is paved with good intentions".

Other features can be produced similarly: unusual recipes (e.g. "coffee surprise": take two kippers; add mixed herbs, pour on boiling treacle and finally smear with marzipan.); news headlines (e.g. PRINCESS ANNE GIVES BIRTH TO SEXTUPLETS - RECOUNT TOMORROW); and libels (of which it would be safer not to give examples).

For a final example of computer-produced language, let me progress from stringing together phrases to choosing whole sentences. At this level it is possible to conduct conversations with a computer, generally rather inane ones. In the following example, the computer was given a repertoire of about 150 trite remarks. Making virtually no analysis of the remarks addressed to it beyond establishing whether they were statements or questions, the program took part in the following conversation. I will leave it to the reader to work out which was the human and which the machine.

   I hope you'll be entertaining.
   I hope you will too, as this is a test run.
   What exactly do you mean by that?
   I want Logophile readers to see you in action.
   What do you think of our dialogue so far?
   You're doing about as well as usual.
   Was that meant to sound obscene?
   No, but you have a strong imagination.
   What do you think machines have to do with your problem?
   I think it's your problem, really.
   You always phrase things so beautifully!
   When are you going to say something interesting?
   Why do you want to know?
   It would make the article more readable.
   Say something profound.
   O.K. - machines are basically stupid.
   That reminds me of a joke my aunt used to tell.
   Was your aunt a machine?
   I won't answer that until my solicitor comes.
   Is your solicitor a machine as well?
   I can't stand around chatting all day.

Jonathan Partington, 1979