How Artificial Intelligence Is Improving Magic Tricks
Computer scientists have designed a trick that uses an algorithm to search the internet for the words most associated with images
Forget lightning speed calculations, technological superiority and machine-like precision. Thanks to the efforts of some researchers, artificial intelligence can now create magic.
“We’ve done a number of different tricks involving artificial intelligence,” says Peter McOwan, a computer science professor at Queen Mary University of London.
McOwan and his coauthor, Howard Williams, recently published a study in PLOS ONE on using search algorithms to scour the internet to find the hidden mental associations magicians can use to astound their spectators.
“A piece of software is like a magic trick in that it has something that seems amazing,” McOwan says.
McOwan says he first got into magic when his father bought him a trick he picked up at a shop while on a business trip. He got hooked, but the hobby kind of dropped away later when he went to university. As he got into computer science, he realized that some of the same algorithms you can use to develop mathematically based card tricks were used to develop software and applications.
“I combined my passion for magic tricks with my passion for computer science,” he says, adding that what started off as a childhood hobby ended up as a whole field of research in artificial intelligence.
“Magic as a hobby is a fantastic thing to get into. It gives you self-confidence, it gives you the ability to learn communication skills—it’s a really good hobby to have.”
While the term “artificial intelligence” is often misconstrued to mean a whole assortment of robot apocalypse scenarios, much of what’s considered AI today is really born from algorithms. But using numbers to create tricks isn’t anything new—in fact many magic tricks involve math.
Jason Davison, a mathematical magician based in London, uses a minor sleight of hand and a few calculations to pull tricks like getting a given card you’ve chosen at any point in a deck you tell him just by shuffling the cards.
Another trick involves using a much more complex understanding of patterns and a little deck fixing to ensure that any way the spectator shuffles a deck, the cards will appear to have an uncanny order in which every set of four cards pulled from the top represent each of the four suits.
“There are many others with algebra and formulaic self-working tricks,” Davison says.
He has even designed a simple computer program that appears to be able to guess the correct color of a given card in a deck fixed in the same way as the latter trick. He gets the spectator to shuffle the cards as above, then divides the deck into two piles. He asks the spectator to guess the color of the cards in one pile one by one before revealing them and enters the answers into the program.
The robot then predicts the other pile, and (un)naturally gets it all right. But what might seem like robot mind-reading is really just a programmatic sleight of hand. Davison knows which colors the cards will be in that pile because they will be the opposite of the spectator’s pile based on the way the deck is shuffled. So when the spectator gets one wrong, he inserts an extra space before the answer he types. This cues the program that the answer is wrong.
So rather than controlling something we can’t comprehend, the program is merely a slave to Davison’s own knowledge of the pack. “The computer ‘guesses’ the coloring of the other pile using this information I have fed to it,” he said in an email.
McOwan has taken algorithms to the next level, though.
His trick works like this. A custom deck will have cards with words, and another pile of cards will have images. Spectators will be asked to instantly choose word cards that associate most closely with an image. (The researchers invite you to download the cards and instructions.)
The real magic in this trick comes in determining how far off the wrong meanings can be without seeming fixed. You might have a picture of a hamburger, for example. But if you have five words—hungry, fish, cat, boat and tree—it will be obvious to anyone which card the spectator will associate with the photo.
If the words instead are hungry, tray, lettuce, bun, and ketchup, the ability to guess the right answer seems much more uncanny though.
McOwan says that in order to determine the precise difference, he used a complex algorithm that searches the internet to find the words most often associated with particular images. The algorithm specifically looks at the words that popular commercial brands use to accompany their products—so in a sense he’s harnessing all the work of decades of marketing research to figure out which word associations we are most likely to make with an image. So even though it seems like you have a choice, your unconscious decision is locked in fate.
“This is basically a new probe into looking at how people’s brains work,” McOwan says, adding that a magician could do this without a program but it would take a huge amount of trial and error before figuring out the most likely answers.
Other tricks he has created with the help of a computer include the design of a jigsaw puzzle that appears to lose simple lines if you put it together a different way. It’s based on a type of illusion in which an algorithm has calculated the amount of changes you can make to shapes without people noticing anything is amiss.
This would be incredibly difficult for a human to design, but a computer program makes it quite easy.
Davison says that other computer-based tricks are coming out with new technology. He talks about trick dice that cue the magician to the numbers they show by sending a signal to a mechanical ticker attached to the magician’s leg, or even trick websites or applications that somehow send messages to magicians.
“I would say that AI definitely has a strong place in magic in the future,” he says.
Brian Curry, a professional magician in the Washington, D.C. area, agrees. He says that some of the tricks that would have astounded audiences 15 years ago no longer pack the same punch because there are apps that do the same work. But new technology can also help magicians stay on top of the game.
“Technology and magic are always correlated,” he says.
McOwan says there are possible uses for artificial intelligence in other forms of magic beyond card tricks. He says that he and other researchers did some initial work on mathematical models for optimizing sleight of hand tricks. It could also be used for designing optical illusions on the stage—tricks such as making a cabinet appear smaller than it actually is and giving someone space to hide in it.
McOwan says that right now, artificial intelligence can only help magicians gain the raw material for a trick. The real magic comes in conjuring up a spectacle, though—the performance art and pulling of a convincing rendition. To that end, while he might reveal to computer science students the magic tricks he creates personally, he considers some of the more clever mathematical tricks employed by professional magicians off limits.
“They are just so so clever,” he says, adding that he would perform them but never reveal them. “I would never give away the real secrets of the trade,” he says.
These computer-based tricks may become more and more popular, Davison says.
“But at the same time, nothing is more glorious than making someone childishly believe in magic again with nothing more than a simple coin.”