Artificial Intelligence is Making Magic Tricks More Magical

For thousands of years, magicians have mixed technology, psychology, and performance to ingeniously hack people’s concepts of reality. But when it comes to creating and tuning new tricks, magicians rely on intuition and trial and error. If two British computer scientists have their way, though, magicians may soon have another trick up their sleeve when designing effects: artificial intelligence.

The researchers developed a “computational magician’s assistant,” which was fed parameters for classic magic tricks. The artificial intelligence (AI) then went to work, generating new trick variants. The work was recently published in the journal Frontiers of Psychology.

magic trick
A magician performs a card trick for a rapt audience.

“Once you realize a trick is based on an underlying mathematical model… you start to think about optimizing it,” said Howard Williams, a PhD student at Queen Mary University of London and the study’s first author. “To us, there seemed to be an opportunity…to make stronger effects.”

The AI-streamlined tricks resonated with test audiences, and one of their tricks, a “magical jigsaw puzzle,” sold well in a London magic shop. The researchers even bundled some of their AI-optimized card tricks into an application available for Android smartphones. It’s the first time that AI has been applied formally to magic tricks, and one of the few research demonstrations showing how AI can aid design in the creative arts.

Magic, “the art of concealing art,” presents thorny design challenges, said magician Joshua Jay. Once magicians “start with a dream” of a desired effect, they combine methods from previous tricks, new presentations, and techniques from across the sciences to generate something new. “Magic tricks are problems to be solved,” Jay said.

The conjuring arts’ use “hidden science and engineering [to] making the impossible possible,” wrote Peter McOwan, a professor of computer science at Queen Mary University of London and the study’s senior author. That makes some of magic’s problems perfect for AI, particularly those where the number of possible methods quickly balloons into the incomprehensible.

In one of the tricks that inspired Williams and McOwan, the magician deals several playing cards to a spectator, who chooses one of them as her own. The magician then asks several vague questions about the group of cards—their color, for instance, or whether or not the cards’ values are “high” or “low”—and based on the spectator’s answers, the magician identifies her chosen card.

The trick relies on a prearranged, cyclically ordered deck, and Williams and McOwan wondered if they could optimize the deck ordering, minimizing the number of questions the magician needed to ask. It’s a daunting computational problem: there are about 8 × 1067 different arrangements of a standard playing card deck. To put that number in perspective, if unique deck arrangements corresponded to individual atoms, it would take about 80 billion copies of our solar system to represent every possible deck order. Even the most ingenious human magician would have trouble looking for the perfect deck amid so many options.

To find the best deck orders, the researchers modeled the trick’s various parameters, like the number of cards dealt to the spectator and the specific kinds of questions the magician could ask. Their algorithm then riffed off of the original deck order, eventually settling on several deck variants that allowed the magician to ask fewer questions—thereby making the trick more “magical.”

Magicians familiar with the study, such as magician and former computer programmer Andi Gladwin, laud Williams and McOwan’s formalized approach to magic’s design process and the AI’s ability to “double-check” magicians’ methods. “The most important idea magicians can take away from this is testing or proving a magic trick…just like we do with user interfaces,” Gladwin said.

Jay agrees. “I think the study’s cool,” he said, “and I think it’s good for magic, so I’m a fan.”

They emphasize, though, that because magic is a performing art, the researchers’ algorithms didn’t create new magic tricks, per se: Magic tricks require emotional hooks and nuanced presentation, too, none of which of the AI evaluated. In short, Jay said, the AI’s output, while useful, is “a million miles from a finished, polished trick.”

McOwan and Williams concur. “Our work in no way devalues the magicians’ art [and] was never meant to,” McOwan wrote, noting that their goals were to highlight new uses of AI and how they could support, not supplant, magicians.

“A spectator doesn’t witness a mathematical event or a computer model,” Williams said. “Hopefully, they witness something that’s kind of impossible.”