There Be Madness in This Method To be and not to be. That was not exactly the question, last time I checked. But that errant conjunction is not the result of a slip of the actor's tongue. In "A Piece of Work," a peculiar puckish riff on "Hamlet" conceived and directed by Annie Dorsen, the text of Shakespeare's play has been run through a series of computer algorithms, turning a canonical work of literature into a scrambled series of minimalist word sculptures. In the process, we in the audience are amusingly (or uncomfortably) restored to the state of excited disorientation we probably first felt when encountering the exotic syntax and language of Shakespeare. To enjoy this "machine-made Hamlet," as it is called, a certain familiarity with the original text is probably necessary. Computers have not, last time I checked, developed a sense of humor, but the algorithms by which Ms. Dorsen has chosen to deconstruct and reconstruct Shakespeare's play often delight with their terse reductivism or sly ability to point up stylistic tics in the text. A large screen at the back of the Brooklyn Academy of Music's Fishman Space, where the show runs through Saturday, is essentially the stage. In front of it, for reasons I couldn't fathom, is a wooden platform with a grave-shaped hole through which stage smoke occasionally belches. On the screen, the names of the characters flash as they speak their fragments of dialogue in voices that have the metallic tang and anonymous inflections of a GPS, an answering machine or dear old Siri. They do tend to have genders, and Polonius sounds distinctly geriatric. Here also appear the stage directions: (Flourish), (Exeunt), (A noise within). As the play flashes by, scene by scene, sometimes these are the only signposts of a particular passage. Characters enter and exit without uttering a line of dialogue, and when they do, it's usually only a fragment or two. The characters" comparative importance in the drama is hilariously reordered. This is the only "Hamlet" I am ever likely to experience in which Barnardo and Marcellus, those bit players who gossip about the ghost before the play proper really begins, get about as much stage time as anybody else. After this initial brisk whiz through the play, we start anew with another algorithm. Trying to figure out what that infernal machine is up to supplies a certain amount of entertainment. The "systems design and text programming" is by Mark Hansen. Aha! It's scanning the text and finding all the two-word sentences in the play, flashing them up on the screen in random order and creating a sort of poem within the poem. Oh, I get it: We're hearing every line in the play that begins with the exclamation "O." As in "O ho!" "O this is the poison of deep grief," "O, this is counter, you false Danish dogs!" O heavy deed! O, my offense is rank, it smells to heaven. The algorithms will bring up different results at each performance. The riddles get harder and more obscure, and are ultimately unsolvable. I gave up trying to read the machine's mind when it started cheating: reassigning bits of Claudius's monologue of guilt at having murdered his brother and usurped his queen to the likes of Hamlet and Gertrude. That's not playing fair, bro, if I may be so intimate. A key to precisely how the five different sections of the production were created appears in the program, but it's probably more fun not to know. In any case, having read the program notes, I still couldn't tell you what the hell a Markov chain is. Although they certainly predominate, disembodied voices are not the only ones we hear in "A Piece of Work." The actors Scott Shepherd, a Wooster Group regular who also starred in "Gatz," and Joan MacIntosh appear at alternate performances, scurrying out from a seat in the audience to recite a soliloquy created on the spot by the computer and piped into an earpiece. It was Mr. Shepherd who gave us that immortal line "To be and not to be," in an amusing parody of a thought-clotted Shakespearean monologue. Mr. Shepherd shaped random phrases he was given as if they were dripping with meaning, but each time a familiar snippet of language turned up, it was followed by the wrong phrase or the wrong word. Scott Shepherd in "A Piece of Work" at Brooklyn Academy of Music. At just over an hour, this certainly qualifies as the shortest version of "Hamlet" I've seen. But to call it a version of the play is misleading. If you expect to find even the basic lineaments of Shakespeare's play here, and to feel the shivers of awe and agony that tragedy can inspire, forget it. The show is more aptly described as a brainiac's jeu d'esprit that succeeds in rendering strange and exotic a play that has become such a familiar text that we take its astounding complexity for granted. "A Piece of Work" willfully confounds understanding, making a merry joke of our dogged need to find order and meaning in art. But in doing so, it reminds us that the original play, whose depths we might complacently assume to have deeply probed, is an eternally confounding achievement, too. A Piece of Work A machine-made Hamlet Concept and direction by Annie Dorsen; performed alternately by Scott Shepherd or Joan MacIntosh; sound and network design by Grégory Beller; scenography/video by Jim Findlay, assisted by, Ryan Holsopple; lighting and technical management by Bruno Pocheron and Ruth Waldeyer; systems design and text programming by Mark Hansen; associate programming by Dylan Fried; additional programming by Mr. Shepherd and Paul Calley; management and production, Audra Diahann Lang/Armature projects. At the Fishman Space, Fisher Building, Brooklyn Academy of Music, 321 Ashland Place, Fort Greene; 718-636-4100, bam.org. Running time: 1 hour 10 minutes.