EH Science: Playing Cards, Boians Cho Joo Young via Technologies Science and Art 

Artificial Intelligence Creates Magic Tricks


Researchers working on artificial intelligence (AI) at Queen Mary University of London have taught a computer to create magic tricks, and audiences are enjoying the results.

The research team is using magic tricks as a means of exploring what artificial intelligence can do. “Using AI to create magic tricks is a great way to demonstrate the possibilities of computer intelligence and it also forms a part of our research into the psychology of being a spectator,” says team member Peter McOwan, Professor of Computer Science. “For example, we suspected that audiences would be suspicious of the involvement of technology in the delivery of a trick, but we’ve found out that isn’t the case.”

The team gave their computer program an outline of how two classic magic tricks work, then fed in the results of experiments into how humans understand magic tricks. Using that data, the system created completely new variants on those tricks which can be delivered as a performance. The magic tricks created were of the type that use mathematical techniques rather than sleight of hand or other theatrics, and are a core part of many magicians’ repertoires.

One of the tricks chosen for the experiment was the ‘magic jigsaw’. Using a clever geometric principle, the trick assembles a puzzle to show a series of shapes, dismantles it, and then the reassembles it so that certain shapes have disappeared. Tricks of this kind involve numerous variations, such as the size of the puzzle, the number of pieces, the number of shapes that appear and disappear, and the ways that the puzzle can be arranged. Something this complex is ideal for an algorithm to process because it can readily make decisions about which variables are most important.

The researchers also chose a mind reading card trick which requires the performer to arrange a deck of playing cards in a specific way. Then, using a few seemingly innocuous pieces of information from the audience, the card that has been seen selected from the deck is identified and revealed on a mobile phone screen via an app. In this version of the classic card trick, the AI is used to arrange the cards in such a way that a specific card can be identified with the least amount of information possible.

Magicians have performed this type of card trick for centuries, but the AI can do it with less information that a human can. During tests, the program identified arrangements for the deck that on average required one fewer question to be asked before the card was found than with the traditional method. By using the app, the magician can perform the trick without having to remember the order of the cards.


Co-creator of the project, Howard Williams, explains to us how a computer can aid magic trick creation: “Computer intelligence can process much larger amounts of information and run through all the possible outcomes in a way that is almost impossible for a person to do on their own. So while, a member of the audience might have seen a variation on this trick before, the AI can now use psychological and mathematical principles to create lots of different versions and keep audiences guessing.”

The tricks have proved so popular with audiences, so the researchers have made them publicly available. The magic puzzle is for sale in a London magic shop, while the card trick is available as an app called Phoney in the Google Play Store.

This research project was undertaken at the School of Electronic Engineering and Computer Science at QMUL. Details of the study are published in the journal Frontiers in Psychology.


Recommended for You