It's around 10 a.m. in the lobby of On the Boards, and director Annie Dorsen is complaining over a cup of coffee that it's "too early" to talk about Immanuel Kant, John Cage, algorithms, "dirty" versus "clean" conceptual art, and what all that has to do with her new project to digitally deconstruct Hamlet. But Dorsen, an Obie Award–winning director and cocreator of the musical Passing Strange, has only herself to blame. She brought it up.

Inside the theater, her team of programmers and designers is busy debugging and fine-tuning "the machine," a complex network of lights, sound, text, and math that will, with the help of actor Scott Shepherd, perform her recombinant Hamlet. Or maybe it isn't "her" Hamlet—the entire show will be auto-generated every night, and even Shepherd is at the mercy of the machine, which will tell him what to say and when.

"We'll just push play, sit back, and watch," Dorsen says. "We're running the show with no human intervention." Her expression is a combination of worried, trying-to-not-look-worried, and thrilled.

This world-premiere experiment, formerly known as False Peach but recently retitled A Piece of Work (she's debugging the title, too), began as a fairly simple game. Dorsen decided to push Hamlet through the grinder of a Markov chain—an algorithmic process that takes a given number of words, then randomly leaps to a logical connecting word, adds the next word, then leaps again.

For instance, take the play's most famous line: "To be or not to be, that is the question." The Markov chain can take "to be" and then leap to "or not," or "that is," or one of the 32 other instances of "to be" in Hamlet. If it leaps to "that is," it can then leap to "the question" or one of the other 10 instances of "that is"—"that is the trumpet," "that is most certain," and so on. All the voices are computer voices, except when the computer tells the human actor to stand up and act.

It sounds cold in theory, but Dorsen was surprisingly moved by computer-generated voices speaking the richly human text when she first started her Markov experiments in 2010. "The gap in expressivity was so intense," she says. "It was kind of heartbreaking—like the computer voices were little half-baked consciousnesses trying to emerge."

She kept pushing the experiment: trying different lengths of Markov chains, trying other text manipulations, inviting Shepherd to be a human voice among the digital ones, and roping in programmers and designers to build the machine. They tagged every word in the play with an emotion score (zero to five for anger, fear, sadness, and joy) and created a lighting and sound system that designs itself in real time, depending on that emotion-data.

Partway through the process, Dorsen surprised herself again when she realized she wasn't just complicating the original game, but directing an actual production of Hamlet—strenuously working through the original text, picking apart the characters and their relationships. "What if Ophelia has access to some of Hamlet's text?" Dorsen asks. "Then she pops out in three dimensions that you don't even notice in the original, where she basically just suffers."

Dorsen noticed that no matter how the machine rearranged things, those original characters were still there, only modified. "I had a similar experience in college when I directed Antony and Cleopatra," she says. "Like, 'Oh my god, he got me! This play is bigger than me! I can't bend it to my will!'"

The durability of the play in the face of deconstruction—our ability to recognize Ophelia even when she gets another character's lines—is one reason Dorsen chose Hamlet in the first place. It is so familiar and so full of its own wordplay that its language games will (hopefully) land with audiences. "It's so central to our consciousness, we don't have to be reverent," she says. "We can deconstruct it, look at the damage it's done, and move beyond it."

What kind of damage?

"Some parts are icky," she says. "A young man surveying the world—it's related to Kant, the idea of a man separate from the world whose consciousness gives him a perspective from which to analyze." She says her larger philosophical goal is to try to help "put the brain back in the body" and "put human beings back into a sane relationship with objects, animate and inanimate... give space, objects, and elements their due. Events are not a product of man's action, but of the relationship between all these objects."

Hence, what Dorsen calls her "semiautonomous networked Hamlet," in which the text is still in the middle, but all the other theatrical relationships (direction, design, actors) are flattened out. Unlike most Shakespeare productions, this Hamlet isn't a hierarchy—it's a process.

But, she hastens to add, it's not a Cage-style process. "It has some relationship to chance-based operations," she says, "but it's different. For Cage, it was a political and spiritual mission to accept everything with a spirit of open curiosity—which, of course, is beautiful and right. But I find myself in partnership with these tools, approaching algorithms to understand how they work. It's collaborative, a dirtier conceptual process. Cage is purer, cleaner. You set up the tools, let it go, and then you adjust to it."

She takes a beat. "On the other hand," she says, "I could make the opposite argument, that Cage spent his life making algorithms, but mostly by hand. The illusion of a pure conceptual process is that you take your intentionality out of it, but I'm not sure you do. I'm not sure you can."

That's when she laughs and says it's too early for this kind of talk.

Apart from proto-Kantianism, consciousness, and wordplay, Hamlet is also about the death of a parent, and the unmooring that happens after one's comforting authority and anchor vanishes. Dorsen's mother had been sick for a while when she began working on the project back in 2010. In 2011, her mother passed away. That, of course, changed her relationship to Hamlet. It started to seem like every little segment in the Markov chain was a distillation of the whole play, dripping with "Hamlet-ness."

"The characters and ideas emerge differently with different patterns, but they're still there," she says. "Sometimes it's like a cri de coeur, and sometimes not. It's like the cycles of grief. People told me before I went through it—sometimes it hits you, sometimes it doesn't." recommended