Enter the maze

The joker in the pack: the computer science

You have learnt the magic. Now discover the link to computer science.

Algorithms

Magicians call a trick like this one, that is sure to work without the need for sleight of hand, a self- working trick. A computer scientist would call it an algorithm.

A finger pressing a numeric keypad

An algorithm is just a series of instructions that if followed guarantees some effect. The algorithm tells you what to do and what order to do it in. Why is this important to computer science? Well, computers cannot think for themselves. All they do is blindly follow instructions: an algorithm. A computer program is just an algorithm written in a language that a computer can execute.

When writing out an algorithm you have to specify the order that things are done. The simplest way of doing this is using sequencing. Here is our joker trick written out as a sequence of instructions. The instructions have to be followed in the order given.

  1. In private place the joker at the top of the pack.
  2. Select a volunteer.
  3. Ask them to pick a small number.
  4. Explain they must count that many cards from the pack.
  5. Show them how by counting the number of cards on to the table.
  6. Add those cards back to the deck.
  7. Ask the volunteer to count the cards out themselves.
  8. Ask them to turn over the top card revealing that it is the joker.

Follow this algorithm, executing the instructions in the given order, and you can be sure the joker will appear on top at the end of the trick.

Human-computer interaction

Phone Rage

If you do the trick following the algorithm, it will work technically. The joker is guaranteed to end up at the top. That doesn't mean it will work as a trick though. The audience might just be left confused or see through it straight away.

For example, suppose you didn't tell the audience just before the reveal that the point was to find the joker. Why should they be impressed that it is that card? It had to be something! The algorithm worked but the presentation let it down. Even though it is not needed to get the joker to the top, a story like the one about teachers helps make the trick work as it gives the trick meaning.

Similarly, if humans are to use programs, then the presentation that sits on top of the algorithm has to be good. The human-computer interface that acts as the intermediary between the program and the user must work too. What is the interface? It is just more program, more instructions. In our trick the part in the middle is:

  1. Quickly, take the remaining cards from the person.
  2. Spread the pack so all cards are visible.
  3. Pick out a couple of cards to highlight and name.

When describing the trick, we could have written the showmanship instructions mixed in with the rest. We separated them out as that makes both parts easier to understand. There are similar advantages to splitting off the core instructions and the interface parts of a program too. It makes the program much easier to write and different members of a team can work on the different parts. Also, programs are often changed after they have been written, as customers want them to be able to do new things. It is much easier to do that if the program is split up with each part doing a clear thing.

Human error

One way your presentation might let you down is if you do not include enough delay after the cards are dealt. If the audience see the two deals together or know immediately where the joker has ended up, they can work backwards remembering what they just saw and so where the joker must have started. By adding a delay and giving them other things to think about, they are less likely to remember what happened.

Many psychologists think in terms of two kinds of memory. Long-term memory is where things are stored that you have actively memorised.

Working memory is where you store things that you are currently processing. Imagine watching a vote-for-the-celebrity TV show. When you remember your favourite's telephone number long enough to dial the number you are using your working memory. You have a very limited amount of working memory. That is why long phone numbers can be hard to remember. People can only hold around seven chunks of information in working memory at a time, like seven digits of a phone number. It's not quite that simple though. If you organise the digits into groups each can become a chunk.

As an interface designer, you have to take into account human fallibility. People make mistakes and some kinds are more likely than others because they depend on working memory. Take car headlights, for example. Have you ever seen a driver get out of a car having forgotten to turn them off?

What was going on? They switched the lights on so knew they were on. They knew they had to switch them off on arrival. They were relying on their working memory to remember, but in the meantime there was a long delay while they did all the driving. Driving involves concentrating on lots of other things that fill up working memory. Eventually they arrived so had achieved their goal. They were probably thinking about what they had to do there. The little tidying-up task of switching off the lights went out the window!

This kind of error is called a post-completion error. They occur when a tidying up task must be done after you have achieved your goal. Ever gone to find something in your room and forgot to turn the light off when you left? Your goal was to get the thing you were after. Turning off the light is just a tidy-up task. Experiments have shown that post-completion errors happen when a person's working memory is filled. If you have lots of other things to remember at the same time you are more likely to make the mistake.

Design principle

Design to avoid human error.

The over-arching design principles for interface designers here is to design to prevent people making these kinds of likely mistakes.

There are lots of ways a designer can help prevent post-completion errors happening. One way is to redesign the order things are done so that the goal is only achieved after the tidy-up tasks have been done. UK cashpoints return your card before they give you cash for exactly this reason. Another way is to give cues. They are just reminders that something needs to be done. For example, modern cars often beep if the driver's door is opened and the headlights are still on.

Dazzling Headlights

Cues are not fool proof though. What kinds of cues work best? Experiments have shown that to be effective in preventing post-completion errors, cues have to be just-in-time. The cue has to appear just at the point when you need to do the action. If the car only reminded you before you reached the destination, for example, then you would still frequently forget.

Back in the magical world, if you were to remind the audience just before the joker is revealed that you had dealt out the cards, you would ruin the magic. Instead help them remember the things that will confuse them: that the volunteer had a free choice and that they dealt that number of cards.