Author Archives: joelg

Genie and the Lamp: 2015 Edition

My final project was a modern take on the Genie and the Lamp story, in which I free a super-intelligent AI from a locked Faraday Cage. Along the way, we have a conversation about the nature of magic and deception.

The role of the AI was played by a Google Nexus Q, a discontinued media streamer/Android device from 2012. The Q is small, black, spherical, and contains a programmable LED ring, all of which (combined with its obscurity/unfamiliarity) give it a very other-worldly, mystical feeling.



The Q sat inside a hinged black cubical box, and was attached to the projector and speakers. The performance was scripted and directed by two complementary Android applications (source available here), one running on the Nexus Q, and one running on my phone. The phone served as a remote – the volume buttons advanced the script running on the Q from line to line. This let me talk for as long as I wanted during our conversation, and still have the AI enter at the perfect time.

I also made use of my NFC deck from my previous project. This was just placed on the table as well.


The Nexus Q required a bit of hacking. I unlocked, rooted, and installed CyanogenMod 11 (based on Android 4.4), just to be able to run the app I developed. I used Google’s Text-To-Speech service (UK English) as the voice of the AI, and used a Parse app for communication between the remote and the Q. I had hoped to use Bluetooth for the remote, since I thought it would be faster and more reliable (especially inside the Media Lab), but the Parse app was simpler to set up and easier to use.

In the middle of the trick, the AI prints out the secret card in ASCII Art. I used this service to convert the a PNG of the card to ASCII art, 100 pixels wide. The “print” function was randomly timed to simulate the erratic output of terminals. Throughout the performance, the AI also printed small, easter-egg-style comments or status messages, for the alter audience members to appreciate.


I tried to make the start a little bit of surprise. In the story, I just happen to come across the AI, so when starting the performance I pretended to have forgotten something in my seat and was on my way to retrieve it when the closed black box called out for help to me.

From there, I acted out the story of meeting the AI, learning about its past, and receiving an offer for it to grant me one wish, a custom it learned from the internet that it thought to be appropriate in this scenario. I wished to be a magician, and from there began a conversation about deception that became the theme and message of the story: that deception can be used to give people experiences that are valuable because of their impossibility.

Along the way, I performed a card trick involving my phone and a NFC-tagged deck, to demonstrate the philosophy that I was trying to explain to the AI.

Here’s a video of the full performance:


I put considerably more effort into writing a narrative for this performance than for previous ones, and I feel like it made off in developing a more cohesive trick that both entertained and has a takeaway message. There were a few points that I wish I could have refined, and a few extra polishes I wish I could have added, like the box closing itself at the end or a more elaborate card trick in the middle, but I was satisfied with where I had gotten the production as it was.

I had a blast this semester, and will definitely be recommending it to friends interested in magic. Thanks for running a fabulous class!

Midterm Documentation

My midterm project was an extension of my Trick++, and used the same deck of NFC-tagged cards I created for that project. This time, I developed the trick to move the reveal away from my phone and onto a volunteers – having the selected card appear on their smartphone instead of simply showing it on mine.

unnamed 0


This was accomplished mostly with software development on my Android app. Since the application can know which card is selected long before the reveal, it isn’t limited to just displaying the image of the card. For this midterm I added functionality to automatically text the card to any phone, or send the card as an email to any address.

On the technical side, this was not difficult to implement. Sending SMS is trivial within Android apps, and required just a few lines of code. Email was only slightly more difficult, since it needs to authenticate with some sort of account, and I decided to just use a Parse app and a free Mailgun account. I also tried to get the app to post the group Slack, but since I’m a restricted user I don’t have the right access privileges.


The code for the app is available here, which is a little better organized than the version from the Trick++. The app has also picked up some other additional features, such as card history/deck tracking, just in case I decided to integrate those into a performance some day as well.

In review: although the in-class performance didn’t quite work out (it ended up being due to 1) my phone’s WiFi being off and 2) T-Mobile’s poor data coverage inside the depths of the Media Lab), I think this trick was an intuitive and natural extension of what I had already built. I wish that I had more time to develop more export destinations (Slack, Facebook, Twitter… anything!), but I think the trick played well as is. This midterm will probably also wrap up the career of my NFC deck, since I have a few separate ideas I think I’d like to pursue for my final.

So long, Magic Deck. You’ve served me well.


D&D Assignment [Joel Gustafson]

If a good format isn’t broke, I won’t fix it. Pardon my blatant copy of Carol’s layout.

Exercise: Create 2 characters from different ability values

Character 1 – Anna

14 con | 12 str | 6 cha | 16 int | 11 dex | 9 wis

Anna is a brilliant mechanical engineer, but her curt, snappy exterior makes people think she’s mean and insensitive, rather than just busy or impatient. She was at the top of her class in college, although many resented her for it. Her few close friends would say that she’s actually a wonderful person, but she thinks her life is too busy to develop too many “unnecessary” relationships with others. She is very dedicated and focused on her job, and although she occasionally has existential crises about the impact and value of her work, they always pass. She drinks a lot of coffee, and was an avid fan of the BlackBerry.

Character 2 – Charles

16 con | 11 str | 14 cha | 9 int | 6 dex | 12 wis

Charles is an easygoing, amiable high school senior who never quite recovered from puberty. He’s clumsy and awkward, but is talkative and self-deprecating enough to make light of it with anyone. He’s a great public speaker and is an ametuer stand-up comedian. He’s an insightful, dependable friend, even though he struggles to apply himself in the real world or in situations where he has to focus and be productive. He strongly believes in family values and patriotism, and he often volunteers in the community. He’s still not sure what he’s going to do for college or a career, but he doesn’t want to be bored by a lot of academics.

Anna and Charles wouldn’t be friends, but they would clash either. Anna simply isn’t invested in developing friendships, but isn’t overtly mean, so their interaction would depend on the circumstance. They’d never sit down for lunch together, but they’d work together if necessary. Anna might get frustrated with Charles’ lack of drive but she’d pick up the slack like she’s used to doing. After meeting, Charles would walk away thinking Anna is a strong, independent woman, and Anna would walk away thinking Charles is an idiot.

Chosen character – Charles Dorn (Character Sheet)

Class – Bard

Charles is a Bard. He was the youngest of all his siblings and it was clear from an early age that he wasn’t as analytical or ambitious. He realized in adolescence that he wanted to be a Bard, but his parents insisted that he try to “apply himself” in something “useful”. He respected his parents and gave it his best shot in school, but he never understood the lofty ideals that they wanted him to pursue. After convincing his parents that he would be a total failure, Charles left home to adopt a simple, straightforward, happy life of a Bard specializing in comedic entertainment. Making people happy makes Charles happy.

Race – Human

The human race is diverse, but it is fraught with ambition, politics, and serious talking. Charles doesn’t like any of it. He prefers not to trouble himself with drama, which isolated him as a child. His family was very aggressive, always trying to squeeze value and capital out everything they could, and always reaching for the next rung of the social ladder. So when Charles expressed to desire to follow that trend, he was mocked by his community as a drifter, a loner, and a dimwit. In reality, he just wanted to be content. He knew how to read people and make them laugh, and that’s all he thought he needed.

Alignment – Neutral Good

Charles is kindhearted, genuine individual, but he has no qualms about deviating from authority or disregarding standards. He didn’t fit in with the society he grew up in, so he abandoned it without regrets. He tries to do the right thing, but sees no reason to go out of his way to do the legal thing.

Alignment Characters 

  • Lawful Good – The Lone Ranger, Superman, most childhood heroes
  • Neutral Good – Forrest Gump
  • Chaotic Good – Robin Hood
  • Lawful Neutral – Claire Underwood
  • True Neutral – Beorn
  • Chaotic Neutral – Sherlock Holmes, Ferris Bueller
  • Lawful Evil – Darth Vader, most organized leader villains
  • Neutral Evil – Frank Underwood
  • Chaotic Evil – Moriarty, The Joker, most psychopaths

Pick two people from the given list. For each one that you pick, write down what you think their strength, charisma, wisdom, intelligence, dexterity, and constitutions scores are.


11 con | 12 str | 13 cha | 10 int | 9 dex | 9 wis

Serena Williams:

15 con | 14 str | 10 cha | 8 int | 16 dex | 9 wis

Trick++ Documentation: Magic Deck

Here’s the documentation for my Trick++ last Monday, which was constructed around a deck that had NFC chips embedded in all of the cards.

Inspiration for this trick came from several examples of computer vision/card recognition tricks I came across online, which creates an interesting performance dynamic: it’s only the computer assistant – not the magician – who knows what the chosen card is. Since I was toying with NFC communication for a separate personal project, it was a natural extension to magic tricks. NFC is obscure and new enough that most people aren’t aware of it (much less anticipate it), unlike cameras or microphones that we’ve been trained are “everywhere”. NFC was the perfect combination of secrecy and subtlety.

Actually constructing an NFC-tagged deck was more work than I anticipated. RFID decks are available online, but cost ridiculous amounts (>$100), so I was forced to build my own. I purchased a pack of 75 NFC stickers from Amazon for $40 (25-pack available here), which was still more than I’d hoped, but much more reasonable. The tags (including the plastic sticker casing) were 12x19mm and just 0.157mm thick (cards, for comparison, are just over 0.300mm), and could store 144 bytes. I found an old, low-quality deck that I wouldn’t mind losing if I messed up and was made of paper stock, not plastic. Then I got a glue stick, an Exacto knife, a needle-nose pliers, a lamp, and a long Sunday afternoon.

The process wasn’t bad once I practiced on a few Jokers (may they rest in peace). Paper stock cards are easy enough to split open from the corners, and I didn’t need cut very deep to slide the chip in with the pliers. I also alternated corners, to try to reduce the thickness increase in the final deck as much as possible. After the tag was in, I used a toothpick to “paint” the inside with glue, and then flattened out the card and put it under a heavy stack of books to set. After iterating through all 52 (miraculously without any card fatalities), I went through them again with the knife to trim any glue left on the edges. The final deck was also slightly thicker than a normal deck, so I omitted 6 cards when performing it so that it appeared the same height. Here’s the final result:


In any sort of ordinary handling, the chips are effectively invisible. If you examine each corner very closely (and get the light to catch just right), you can notice warping, although I think that is more of a result of the glue than of the chip.


The deck itself was only half of the trick. On the software side, I used a generic NFC reader-writer on the Google Play Store to write each cards’ name on it. The format I used was a two-character text string, like “4h” for the Four of Hearts or “td” for the Ten of Diamonds.

Once the cards were all encoded, I build an Android app that automatically launched itself upon contact with any of those cards, and displayed the appropriate card image. The app filters for the ACTION_NDEF_DISCOVERED intent and for text-only tags, and will launch itself whenever the phone comes in contact with one regardless of if the app is open or not (thanks Android!). The code was extremely hack-y, relied heavily on examples here and here, and I’m deeply embarrassed for ever having written it, but it is available here if anyone would like to use it for themselves. Otherwise you can get the .apk here.

Here’s a short video of the app in action:

Having created the mechanics of the trick, I then needed to construct a performance around it. I felt like I really under-utilized the potential here – there are so many possibilities that the deck opened up I hardly knew where to go to properly take advantage of its strengths.

I practices a few variations in which I would have the volunteer pick a card, which I would wave around and casually bring it near my phone in my pocket. This was rather awkward, since it’s not a natural place to leave your hand hanging, especially when it’s holding something so important. Also, “checking” my phone later on aroused a lot of suspicion.

I eventually settled on a routine built around me leaving my phone face-down on the table, then slapping the card down on top of it. Forcefully slapping things on tables seems to be a common theme in a lot of magic tricks, so it didn’t arouse too much suspicion in my practice runs – most people thought it was just showmanship, not a critical part of the trick itself. Here’s a video of one of my practice runs:

But I couldn’t just let a volunteer pick a card and then immediately slap-reveal on the phone – that would be far too obvious and, much worse, far too short for a trick like this. Instead I decided to try to purposefully obfuscate the performance so that the audience would have theories. I decided to start with a complex, unimpressive trick – a performance that would hopefully leave the audience with several theories. My original plan was to perform the same trick three times, with each repeat explicitly whittling down the possible theories until none remained. In class, on a whim (that I regret taking), I decided to only perform it twice. Here’s the final presentation, complete with spur-of-the-moment patter that tried to “explain” why I’m slapping the card down on the phone:

… “Now… It seems like some of you think this is just a magic trick. And your suspicions are well-founded – I mean, I got see the card myself, and I could have interacted with the phone in all sorts of ways. But to show you that this is, in fact, a legitimate scientific experiment, I’m going to do the trick again…”

I need to say “um” less often.

I’ll probably stick to my NFC deck for at least the midterm project, and am really searching for ideas on how to expand the presentation. How can I take full advantage of this technology?

What would you do with a magic deck?