You are stooped in a fet- id, gore-slathered grotto far underground. Through the murk a troll appears and leaps to split your gizzard with an axe. You're holding the jeweled egg, the elfin sword, the brass lantern and a brown sack smelling of hot peppers. The axe descends. Half a hundred options seethe in your skull. Clamped in panic, you stare at the keyboard. And on a sudden desperate whim, type: Throw the sack at the troll.

Your disk drive snickers, the video screen pulses and flares:

The troll, who is remarkably coordinated, catches the brown sack and not having the most discriminating taste, gleefully eats it. The flat of the troll's axe hits you on the head . . . I'm afraid you are dead.

Rats.

If it's 2 in the morning, this must be Zork. Not even Ted Koppel can keep the nation up so late--or so long, with an average play-time of 30 hours. Yet the plot-it-yourself all-prose adventure is America's best-selling personal-computer game and the simplest of 10 cranium-spraining odysseys from the house of Infocom. Its programs now hold seven of the top 20 game slots on the jealously watched Softsel Hot List--and all without a single picture.

Instead, they have tapped the most powerful image-generator known: the human mind. "One of our groups is working with graphics products," says Infocom president Joel Berez, 29. "But we're going to stick with text. Your imagination is much richer than the rather crude graphics available on microcomputers."

Sounds simple as falling off a floppy. But to harness that capacity, a team of software shamans has had to travel to the outmost eerie perimeters of artificial-intelligence research. And to evolve a new hybrid genus: the writer-programmer whose cosmos is both in and out of his control. Game author Dave Lebling puts it this way: "Shakespeare did not have to worry about what happens if Hamlet decides to kill Claudius in Act I." The Birth of a Notion

You are standing in the bland-hued hallway of Infocom. To the west is a wooden door, ajar. Behind it, Berez and production manager Michael Dornbrook, 31, are plotting expansion. To the north is a rack of computer magazines, edges thumbed to fluff. To the south, an open corridor leads out of this warren of tech-biz office suites and into the placid shoppe-scape of Cambridge. To the east is a closed door. Behind it the game writers are holding their weekly conclave. At intervals, a blast of hilarity rattles the jamb: deep rasping sobs of laughter, a tremulo of giggles, a tweetering scree like a jungle bird. Then the sound of chalk on a blackboard.

Walk west and enter the office:

"It all began," Berez is saying, in the mid-'70s at MIT's Laboratory for Computer Science, where a dozen researchers--among them Berez, Marc Blank and Dave Lebling--were developing programming tools for interactive artificial-intelligence problems. "You have to understand that we always had a competitive feeling that our people could do many things better than anybody else." (American programming primacy is split like the medieval papacy between Cambridge and the West Coast. At present, the top doggies in business software Lotus and education Spinnaker are also in Cambridge.) So when a strange new dungeons-and-dangers game called Adventure--now $24.95 from Norell Data Systems in Los Angeles--popped up on the mainframe one day, the boys were cranked.

Especially Blank, now 29, a high-strung polymath and Infocom's vice president for product development. He was designing and developing MDL (known as Muddle), a high-level language for computers, while commuting to MIT from Albert Einstein Medical School in New York. Blank and Lebling (now 34 and still affiliated with MIT) began writing their own game, replacing the two-word commands ("take sword") with more complex syntax. By 1978, cybernauts all over the country were playing the game, which was kept under the heading Zork--"one of Marc's nonsense words," says Dornbrook.

But by 1979, the MIT bunch was breaking up; so Berez and Blank--who had just finished his MD--decided to start a company, sell the game and keep the gang together. Testers were recruited (MIT-vets Dornbrook, his then-roommate Steve Meretzky and Stuart Galley--the latter two now game authors) and Zork was licensed to a rookie outfit called Personal Software for marketing. There it might have remained had Personal Software not invented a financial program called VisiCalc--which flared into acclaim and helped detonate the personal-computer boom. The company became VisiCorp, now an industry giant, and dumped Zork as unbecoming to their new image. Infocom swallowed hard and in 1981 went it alone. The rest is very lucrative history. And very hard work. Miming the Mind

Artificial intelligence programming seeks to synthesize the process of human decision-making. The most primitive form is either/or branching: In interactive arcade games, you either hit the alien ship or don't; in simple medical diagnostic programs, you show a fever or not. Infocom, however, offers not only 10 directions of travel and a wide range of actions (read, wave, burn, drop, give to, climb up, look under, etc.) but the power to act irrationally--e.g., lobbing the chow sack at the troll. "We're testing one new game now," says Dornbrook, "in which the player is able to turn himself into a bat. But he's also capable of traveling under water. So naturally, somebody turned himself into a bat under water. We're trying to decide what to do."

All of which would be impossible, Blank says, without two tools. (A favored programmer's word--as if it were palpable as mallets and awls.) The first is Infocom's proprietary programming language, ZIL (Zork Interactive Language). In so-called "rule-" or "frame-based" systems--like the medical example above--the facts fed in by the operator proceed through a sequential, hierarchical route called "chaining" to reach a conclusion.

An alternative method is list processing (hence LISP). The Info-folks intimate that ZIL is of this latter type and akin to Muddle; beyond that, they are mum. Such systems do not require a fixed sequence of stages. Whereas the basic unit of rule-based programs is a word or number (female, blood pressure 120/80) LISP-like systems employ symbols for clusters of characteristics or definitions of states (i.e., all the activities associated with the verb "burn"). When new data arrive (the player encounters a rock and types Burn the rock), the program examines the associations between "rock" and "burn"--and finding no match, generates an appropriate response: "You're nuts." Of course, the lists themselves may contain lists; and many routines are "recursive"--that is, start themselves automatically. Picture a possible universe of 255 objects (each with its string of characteristics) and a vocabulary of 600 words (each of which has various possible associations with the objects), and you begin to see the scope of the problem.

Not to mention the "parser," which allows the program to understand whole sentences like "Pick up the troll-wand and the rubber gerbil and give them to the Bog Monster. Then follow the magic chicken." Or permits game-players to address characters individually--"Monica, tell me about the muddy footprints." The very mention of this arcane appliance, now in its fifth rewrite, provokes a horrified awe even in writer-programmer Michael Berlyn: "It's clearly the most complicated, convoluted, disgusting piece of code that's ever been written. And modifying it means handling it like a bomb--but with a sledgehammer at the same time."

Forget about popping it in your Atari. The games are developed and "debugged" on Infocom's almighty mainframe DEC-20, the biggest byte-bender in Digital Equipment's fleet, compared to which your IBM PC is dumb as a toaster. The program is compiled--translated into chip-legible binary code--and then adapted to 15 different computers by adding a "kernel" allowing each machine to interpret the code. The Write Stuff

All of which somewhat narrows the range of potential authors. "I can't tell you how lucky we've been that we have good writers who are also programmers," says Berlyn, 34 (Suspended, Infidel, Enchanter), the group's gregarious de facto spokesman. You can see it in the hybrids spread around this conference table: The rumpled, linty look and blinky, oblivious aura of the cyborg; but a brightness of eye evincing acquaintance with reality. Especially in Berlyn, a sci-fi novelist ("Crystal Phoenix," "The Integrated Man"), former head of a software house in Colorado and the only non-MIT alumnus, who fled East out of raw zeal for Zork. "I sat down at an Apple years ago, played it, and said 'Next!' I was hooked, I needed more--and there weren't any!"

A typical syndrome, it seems, as each springs to tell the others' stories. "What you're seeing in action," says Berlyn, "is the way we work as a team." Lebling, 34 (Starcross, Zork I & II), is a programmer and "frustrated writer" with a background in political science. Galley, 39 (The Witness), studied physics and worked on his college newspaper before MIT and Infocom; Meretzky, the youngest at 26 (Planetfall), took architecture and engineering before embarking on film scripts and technical writing. If the games share a propensity to sardonic wit and stylistic burlesque, well, says Berlyn, "a lot of it is because the people originally involved weren't computer nerds."

In fact, Meretzky "hated computers," Dornbrook says, "and was constantly complaining about this Apple I had on the table" to test the early Zork. "I was appalled," says Meretzky. "Most of the people I knew who used computers were totally boring and never talked about anything else." The image was reinforced, Lebling recalls, when the original Zorksters would convene at a Chinese restaurant to talk tech. ("For some reason," he says, "all computer programmers love Chinese food." "I've got a theory," Galley injects: "It's because Chinese dinners are modular." A round of knowing laughter.) Anyway, "we thought, wouldn't it be great if poor Steve had to sit through this." He did--and much more. "Pretty soon," says Dornbrook, "I'd come home and notice that things were moving around on the table." Meretzky was a goner: "So when Mark did Deadline, and needed someone to test it, I did. Six months later I started writing."

A single writer originates each project, but the process soon becomes collaborative, with solutions and scenarios proffered, swapped or stolen. ("Occasionally," says Galley, "we hate each other.") But generally, says Berlyn, "the ambiance is like a dorm room where people will be wandering through the halls, coffee cup in hand, zombielike, and say, 'Do you mind if I sit and watch you work?' " So in the case of Suspended, "I did not in any way, shape or form write the whole thing," says Berlyn, although "whoever has the responsibility gets the credit." Once the writer gets his theme, goal and adversary approved, he begins with a blank screen, an uncreatured void with four compass directions. "You get to wander around in this pristine universe you've created," says Berlyn. Geography is added, then traps and hostile characters, the prose descriptions fattening with the complexity of the problem.

Up to a point, it's routine back-plotting, says Berlyn. Infidel begins on the desert, in a tent with a locked chest, "so I can either give them a key or allow them to break the lock. So what do I give them to break it with?" But "at certain stages," Lebling says, "you are about as close to being a full-fledged programmer as anybody writing an accounts-payable package." With comparably maddening problems.

To wit: Say a player is permitted to get a knife and a loaf of bread. "Suppose he cuts the bread in half, and then that piece in half, and then tosses one piece five feet away?" Not only will the program have to stop the player from slicing away indefinitely like Zeno's paradox, but the tossed piece suddenly becomes part of the interactive geography. Why would anybody start whacking at the loaf? "The point," says Berlyn, "is that someone will want to do it." (Hence deceased characters customarily disappear in a vaporous puff, lest their corpses become one more item to throw, take, etc.)

Moreover, the games usually feature a berserk antagonist programmed to appear occasionally. In Zork II, Lebling created the esteemed Wizard of Frobozz. "He's a little bit senile," says Lebling, "and he's forgotten all the spells he used to know except those that start with F." So he casts enchantments like "fumble"--causing them to drop things--or "fluoresce," which causes them to light up. Worse yet, certain events are programmed to occur at random. "In Zork II, I've got a topiary garden. Every so often out of the corner of your eye, you can see one of the animals move. One time out of 300, it will attack." Cerebral Limits

The cerebral strain is such that "a lot of our humor and snide remarks are a frustrated response" to the imagined demands of players, says Berlyn. "It's like, 'Hey--you're asking the impossible." And they do: In cascades of mail and as many as 400 phone calls a day for hints. "There's a lot they shelter us from," says Meretzky. Berlyn groans. "I get calls at home. This voice goes, 'Hellloooooo?' and my wife says, 'This is not someone we know.' " Still, "there's this person groveling on the other end, saying, 'Please, please! I need help. There are 18 of us . . .' "

Do they worry about propagating that addiction? "Yeah," says Berlyn. "We're up all night biting our nails." Not even the chorus of carpers warning that America's nippers are turning into microchip golem? A pause, a whiff of burnt umbrage. "You mean," Berlyn shoots back, "that Johnny will never be able to read? Not in our games. You mean Johnny will never be able to think his way out of a paper bag?" He's got a point; and Infocom's got a trophy case of awards from parents' associations. Besides, the next generation of bogglers is even more demanding.

"The one I'm doing now," Meretzky says, "is a time-travel game where you meet yourself in the future and have to exchange objects. It's probably the most complicated problem we've ever worked on," especially since the quest runs through "a coal mine where there are 27 different things to worry about." He lets that sit for a second. "But nothing that's not in a day's work."

Case in point: Suspended, so viciously complex it makes air-traffic control look like mah-jongg. In ZIL, says Berlyn, "there's a program that's running all the time that knows the state of the universe and all its variables and acts accordingly. In Suspended, I broke it." In the game, a player, immobilized in cryogenic suspension, must repair the damaged life-support systems of an artificial planet by directing six different robots--each of which has unique capabilities and deficiencies. Each moves independently of the others (and of the player!), and one is used to query the planet-computer's main data base. All the while, the ecosphere erodes and the death toll rises. Infocom estimates a minimum of 30 hours to reach a conclusion. Berlyn--who like the others enjoys playing the games as much as writing them--didn't know the limits of Suspended until it had been tested. Even now, he gets "far from the best score."

The Witness--written in a Raymond Chandler lampoon style--gives the player-detective 12 hours to solve a crime and the ability to interrogate characters, examine evidence, and to decide whether or not to answer a ringing telephone--and if so, to choose what to say. It follows the super-seller, Deadline, as the second in Infocom's mystery series. A mere 30 different endings are possible, and a set of newspaper headlines at the end show you how close you were to the ideal solution.

This fall the company stretched its sci-fi line with Planetfall, a comedy space adventure in which an enlisted man (armed only with a broom and a robot sidekick named Floyd) tackles the terrors of a strange planet. (The player must not only eat and sleep at prudent intervals, but interpret his own dreams.) And it started two new series: a fantasy line (Enchanter) in which a fledgling wizard must acquire a repertory of spells to subjugate an evil warlock; and a Tales of Adventure line (Infidel) wherein the player-archeologist makes his way to the core of a lost sacred pyramid.

Juggling the code in the monster mainframe, writers can complete a game in three months. (It would take three or four years, Blank says, to write one like Deadline in standard machine language--"and then you'd only have it running on one computer.") But that's only the beginning. For the next two months, the programs are given "to our employes, who are paid to really beat on 'em," says Dornbrook. Their error reports and suggestions are compiled in a "bug book" that can reach 1,200 pages.

The games are fixed, embellished, then shipped out to a second tier of a dozen outside testers. When they reply, the program is re-edited again. "We've even had the ending of the game changed at this point," says Dornbrook. (One player objected that Infidel unfairly rewarded the arrogant ethnocentrism of the anthropologist. The staff concurred, and the game altered accordingly.) Still, "every game goes out buggy," says Blank, and is constantly being modified: Zork I is now at Version 75.

"We're not standing still," Meretzky says. "We're pushing back the envelope." With games? A visitor, amused at this heroic allusion to "The Right Stuff," guffaws. Into silence. If the product is entertainment, the process is serious. And each is pushing his own way. Galley wants to see "more human interaction, a romance story maybe"; Blank a program so sophisticated that one could, say, dicker with a shopkeeper over the price of an item. Meretkzy likes temporal realism demanding "sleeping and eating and different things taking different lengths of time." And Berlyn prefers "six characters running at the same time." But in the end, it's the public whose wishes count. "Reviews mean infinitely more to us than to a novelist," says Berlyn. "In games, you don't know what people like until they do it." Hard-Sell Software

It takes annual sales of approximately 20,000 copies to make a game a best-seller. Infocom's, most at $50 each, grossed nearly $6 million this year--up 400 percent, Berez says, from 1982. No wonder Softline, the computer-game magazine, now carries a special "Zorktalk" column; or that Addison-Wesley has just signed to distribute the games to booksellers. And this spring Infocom will release a new line for ages 8 to 13. Lately, "we've made an attempt to separate the programming from the actual game writing," says Berez, "and our intention was to bring in big-name writers." So far they've secured a weathered yarnwright from the Tom Swift and Hardy Boys book series. And there'll be a game specifically for girls.

That may seem odd, since the nation's 4 million personal computers (a $2.2 billion retail software market) are overwhelmingly run by males. But astronaut Sally Ride, who braved the yawning vacuums of space, says "Zork is going to drive me to my knees." And this month's Ms. magazine lauds Deadline for promoting "logic, deductive reasoning and other problem-solving skills."

To some, the skills are the problem. A Texas mom whose 11-year-old twin sons got Deadline wrote Infocom in a lather of rage. "Now, after two weeks of new questions directed at me regarding mixing alcohol and drugs, murder and suicide," she wrote, "the real clincher came" when one of the boys came in and "said his brother just 'raped someone in the living room' while playing the game." What's a mother to do? She decided to buy the game back from her kids. Infocom fired back that if Deadline talks about drugs and mayhem, "so do virtually all mysteries" and although the program understands the word "rape," "it never uses the term itself." And the consequences are "arrest, prison and disgrace. Not exactly encouragement."

But then, the tricks aren't for kids. Infocom's average player is between 18 and 35, and Popular Computing's reviewer this month concedes that it took him several nights and 30 pages of handwritten notes to get through the first third of Suspended. Even the avid may lack the time. "It's definitely addicting," says Abe Nainan, 22, who works in a Bethesda computer store and used to take the games home. "But I just refuse to do it any more. I need to do other things--like eat dinner." Isn't Infocom shooting itself in the financial foot with stuff that takes two work weeks to finish? "It's a concern," says Berez. "But the trade-off is, you want your customer to be happy." Besides, "some people get disappointed if they finish." And of those who do, says Dornbrook, "the average person doesn't see more than two-thirds of the whole game. I doubt that anybody sees all of it." How many outcomes are possible? "We once thought," says Berez, "that it would make an interesting doctoral thesis."

Some of Infocom's success is owing to its lavishly baroque packaging. The Witness comes with a replica of a 1938 newspaper (in one column of which appears the game's fictional suicide) and a real matchbook; Infidel has a parchment map, Planetfall a plastic ID card. They contain invaluable clues, serve "to get you into the mood, the context, before you even boot up the disk," says Dornbrook, and discourage the disk-copying piracy now epidemic among home users: Infocom's games are barely playable without the oversize, wierdly textured and oddly folded documentation; and you'd go bonkers trying to Xerox the stuff.

Of course, you'd probably go bonkers anyway, as Dornbrook found out. Even in the early days, "we started getting letters and calls, people saying, 'I'm confused!' They'd get totally lost and desperate." He got the idea of selling maps, and when he went off to business school in Chicago, he founded the Zork Users Group. "I figured this was gonna be a few hours a week," but membership bulged to 20,000 and soon ZUG offered a full range of Zorkiana: T-shirt transfers, bumper stickers ("Rather Be Zorking"), maps and posters, with beer mugs and more on tap. A veritable cultmeister. "I used to worry about things like that. So I never announced my last name or signed an official letter."

This year he rejoined the company. The T-shirts had to go ("We're trying to develop a professional image," says Berez), but Infocom has coopted ZUG's greatest hits: the maps and the chemico-cunning InvisiClues, a $7.95 booklet in which two or three progressively more obvious hints for each problem are written in invisible ink. Dosing each line with a special felt-tip marker activates the "latent-image process." Read 'em or weep.

Dornbrook believes Infocom's games are "the beginning of a new art form," one that "could be a significant percentage of book reading 20 years from now." Particularly since they're on the verge of "a major, major increase in sophistication," a synapse-broiler of such cabalistic complexity that "I was thinking of marketing it as The Last Game You'll Ever Play."

For Blank, there's another payoff. He'll sometimes surreptitiously watch a player, and "the nicest thing anybody ever said while I was watching is, 'You can tell these guys really love what they're doing.' "