Don’t throw away your Stephen King collection just yet. But the Master of the Macabre might want to keep an eye out behind him, because scientists have just unleashed a nightmare machine on a mission to churn out its own bone-chilling tales.

MIT researchers have applied the electrodes and brought to life a new fiction-writing bot they call Shelley — after “Frankenstein” author Mary Shelley. To keep the bot busy — no wandering the countryside terrorizing villagers! — the team gave it a crash course in the horror genre, forcing it to read 140,000 stories published by amateur writers on a popular online forum.

Now Shelley’s artificial neural network is generating its own stories , posting opening lines on Twitter, then taking turns with humans in collaborative storytelling.

COLD, CALCULATING HORROR

“She’s creating really interesting and weird stories that have never really existed in the horror genre,” said Pinar Yanardag, a postdoctoral researcher at the MIT Media Lab. One strange tale, for instance, involved a pregnant man who woke up in a hospital.

The lab’s experiment, launched in time for Halloween, follows a similar project to create scary images last year. But can all that deep-learning technology and powerful computation truly turn out terrifying tales? Let’s just say the experiment is still in progress.

King, the world’s most famous living horror writer, has said it can take him “months and even years ” to get a novel’s opening paragraph right. Shelley takes a couple of seconds — and the results can be a little awkward.

“The doll came at me with a syringe,” the bot posted on Twitter on Friday. “Its blood shot out of its mouth, and it began to uncover itself. It was then that it began to dance.”

ITS INSATIABLE APPETITE … FOR DATA

Shelley’s sentences are inspired by the hive mind it’s learned from: a crew of horror hobbyists who participate in Reddit’s “r/nosleep” forum . Machine-learning algorithms are fueled by big troves of data, and these amateur writers have produced about 700 megabytes of home-grown horror over the past decade. The researchers didn’t train Shelley in the genre’s classics, both for copyright reasons and because there just aren’t enough of them.

“If you look at all the literature by Lovecraft or Stephen King or Edgar Allan Poe, it would be just a few megabytes,” said MIT research scientist Manuel Cebrian. “We would still not have enough data.”

Yanardag and Cebrian are themselves aspiring horror fiction writers. While readers might not be buying Shelley-produced books anytime soon, the system learns from the feedback it gets, and might help nudge a human writer into thinking more creatively.

“You tend to get stuck,” Cebrian said. “This kind of technology helps you write the next paragraph so you don’t get so-called writer’s block.”