Dungeons & Dragons turns forty this year. The game, which I played in my youth, is entering middle age just a few years behind me. My interest in—or, I should say, my obsession with—D. & D. coincided with the height of its popularity, in the nineteen-eighties. D. & D. was more than just a fad or a hobby. It was a subcultural sensation that popularized the idea of role playing and ushered in a seminal change in the way games were created and enjoyed. Instead of pieces or figurines, there were characters—avatars—who the players inhabited; instead of a board or a terrain table, there was a fictional world that existed in the shared imaginations of those who were playing; and instead of winning and losing, there was, as in life, a sequence of events and adventures that lasted until your character died. These concepts are now commonplace in our online lives and our recreational activities, but four decades ago they were revolutionary, and a key part of D. & D.’s addictive quality. By 1981, more than three million people were playing Dungeons & Dragons. It soon joined “The Lord of the Rings” and “Star Wars” in a kind of high-nerd trinity—one that, with “The Matrix,” “Harry Potter,” and “The Hunger Games,” has long since entered the mainstream pantheon.

For much of its existence, D. & D. has attracted ridicule, fear, and threats of censorship from those who don’t play or understand the game. It is surrounded by a fog of negative connotations. David M. Ewalt, the author of “Of Dice and Men: The Story of Dungeons & Dragons and the People Who Play It,” writes, “If you’re an adult who plays … you’re a loser, you’re a freak, you live in your parents’ basement.” The game has been accused of fomenting Communist subversion and of being “a feeding program for occultism and witchcraft.” One mother, whose D. & D.-playing son committed suicide, started an organization called Bothered About Dungeons & Dragons (BADD).*

Though that negative perception is changing, as popular culture and the fantasy milieu become increasingly synonymous, I believe that the benefits of D. & D. are still significantly underappreciated. Though its detractors see the game as a gateway to various forms of delinquency, I would argue that the reverse is true. For countless players, Dungeons & Dragons redirected teen-age miseries and energies that might have been put to more destructive uses. How many depressed and lonely kids turned away from suicide because they found community and escape in role-playing games? How many acts of bullying or vandalism were sublimated into dice-driven combat? How many teen pregnancies were averted because one of the potential partners was too busy looking for treasure in a crypt? (Make all the jokes you want, but some of my fellow-players were jocks who had girlfriends; sometimes the girlfriends played, too.) How many underage D.U.I.s never came to pass because spell tables were being consulted late into the night? (It’s hard to play D. & D. drunk; it requires too much concentration and analytical thought.) Just this week, the Times published an article about the game’s formative influence on a diverse generation of writers, including Junot Díaz, Sherman Alexie, George R. R. Martin, Sharyn McCrumb, and David Lindsay-Abaire. (To the Times’ lineup, I’d add a murderers’ row of Ed Park, Ta-Nehisi Coates, Paul La Farge, Colson Whitehead, and Sam Lipsyte.)

D. & D.’s positive legacy can also be seen outside the worlds of literature, cinema, and video games. The predatory dangers of a dungeon are good preparation for the cutthroat world of business. My friend Paul Taylor, who was the Dungeon Master for many campaigns I participated in during the eighties, went on to found two successful technology companies, the second of which was acquired by Google. In an e-mail to me, he said that Dungeons & Dragons helped train him for the rigors of tech entrepreneurship. Furthermore, he said, he sees a parallel between the unpredictable ways in which people use new technologies and the ungovernable ways that players navigate their way through a D. & D. campaign: “No two versions are alike.” Snooping around the Internet, it didn’t take me long to discover a list of Leadership Lessons from Dungeons & Dragons.

A forthcoming documentary about the game characterizes D. & D.’s origins as akin to Facebook’s: “A cautionary tale of an empire built by friends and lost through betrayal, enmity, poor management, hubris and litigation.” Wizards of the Coast, the company that has owned the D. & D. franchise since 1997, is marking the anniversary by releasing a new starter set this week; the “Tyranny of Dragons” digital story line will launch in August, along with a revised print edition of the player’s handbook; in September, the new monster manual will be published, followed by a revised Dungeon Master’s guide, in November.

In the past forty years, Dungeons & Dragons has come a long way from its humble beginnings in the basement of E. Gary Gygax, a high-school dropout living in Lake Geneva, Wisconsin. Gygax was working as an insurance adjuster and a self-taught shoemaker when he turned his hobby playing war games into a vocation and a business. Dungeons & Dragons emerged from the world of military war games—complex scenarios in which great battles of the past are reënacted with miniature plastic or metal soldiers. Through a series of collaborations with other war gamers in the mid- to late seventies, Gygax and a Minnesota gamer named Dave Arneson came up with an initial set of rules, which as a work in progress were known simply as the Fantasy Game. With borrowed money from another gamer named Brian Blume, they, along with Don Kaye, formed a company called Tactical Studies Rules (T.S.R.) and printed an initial run of a thousand copies. The first sets were assembled by hand in Gygax’s basement and went on sale via mail order in January, 1974. (If you want the full origin story, read Paul La Farge’s 2006 essay on D. & D. for The Believer, pick up a copy of “Of Dice and Men,” or wait until the documentary is released.)

The war gamers that Gygax and Arneson knew took up the rules with great enthusiasm, but the first run of D. & D. sold slowly. (Gygax said later that he estimated the potential audience for the game would be fifty thousand people.) Gradually, word spread, and sales picked up. It took nearly a year for the first thousand copies to sell. The second thousand went in four months. T.S.R. also introduced other games, including one based (without permission) on Edgar Rice Burroughs’s John Carter novels. A regular newsletter was launched. Soon they were printing supplements to Dungeons & Dragons, licensing the product to other vendors, and expanding their business horizons. The rapid growth was accompanied by a soap opera of broken friendships, lawsuits, changes of ownership, and failed initiatives. Gygax lost control of T.S.R. and ended up moving to Los Angeles, where, separated from his wife, he lived in King Vidor’s Beverly Hills mansion, hosting hot-tub parties and pursuing a deal for a movie based on the game he had helped to create. Further turmoil followed. T.S.R. went into debt and was sold to Wizards of the Coast. Gygax moved back to Lake Geneva, where he died in 2008. His funeral turned into an impromptu gaming convention, which is now called Gary Con and meets each year on the anniversary of his death.