There’s a type of story we’ve come to expect from M. Night Shyamalan, and it basically resembles the premise of Wayward Pines, a 10-episode “event series” premiering Thursday on Fox. Here’s the setup: A Secret Service agent named Ethan Burke (played with steely resolve by Matt Dillon) is sent to a mysterious town in Idaho to investigate the disappearances of two fellow feds. Along the way, Burke gets in a car accident, which kills his partner and leaves him stranded. From the hospital, he attempts to call his wife but can’t get an outside line. Eventually, he tracks down one of the missing persons, and she’s somehow many years older than when he last saw her weeks earlier. It dawns on Burke that this town exists outside of the time-space continuum. When Burke tries to leave, he can’t — there are shadowy creatures lurking just beyond a massive wall that encloses the town. Of course, it’s also possible that he’s hallucinating the whole thing. Will Ethan be able to escape? You’ll never guess how it ends!

If you were to take a shot for each Shyamalanesque plot device, an episode of Wayward Pines would constitute the shortest drinking game ever.

But while he’s the show’s co–executive producer and director of the taut and evocative pilot, Shyamalan isn’t the mastermind behind Wayward Pines. That distinction is actually shared by creator Chad Hodge, a veteran TV writer and producer whose previous projects, the CW’s Runaway and NBC’s The Playboy Club, were, shall we say, involuntary limited-run propositions, and author Blake Crouch, whose successful trilogy of e-books provided the basis for Wayward Pines. Like Ethan Burke, Hodge found himself instantly ensconced in Crouch’s paranoid, upside-down world the moment he dug out the first Pines book from a pile passed along by his friend Donald De Line, a movie producer looking to develop a television property.

“I loved the single-player nature of the storytelling — it was kind of like a video game,” Hodge, 37, said. “You go in with this guy Ethan Burke — you are this guy — into the town. There are all these twists and mysteries set up, and question marks are compounded on each other. I felt, like, There is no way this is going to add up to something that’s going to make any sense at all. We’re so conditioned to being let down by endings — endings to big, mysterious stories that are never as satisfying as you want them to be.

“When I got to the end, and I read what the truth of the town was and how it literally plugged every hole I thought there was in the story, I was in awe of what Blake Crouch had created and immediately knew I had to do it,” he said.

Hodge was so enamored of Crouch’s books that he wrote the pilot script for Wayward Pines on spec, meaning he worked for several weeks without the guarantee that he’d ever get paid. This was partly motivated by the impossibility of explaining the plot in an elevator pitch — Hodge doubted that any network executive would give him time to explain the government conspiracy, the murder mystery, the race of genetic mutants, or the secret society of elite teenage thought leaders that are integral to the story. Wayward Pines doesn’t unfold as much as spill forward like a box of tiddledywinks, sending various plot points in diverging directions with little discernible sense of how they’ll eventually connect. For the pilot, Hodge figured it would be easier to simply show networks a script that gave a sense of the uniquely creepy-campy tone he was after.

“Because of the nature of the show being so mysterious and intentionally confusing — a sort of ‘what the fuck’ genre — I thought, If I can write a script that makes readers feel the same way I felt reading the book, we’re gonna win,” he said.

Hodge and De Line sought to sweeten the package by attaching a well-known movie director, and Shyamalan was at the top of their list. Shyamalan admittedly hasn’t topped many lists lately — after 1999’s The Sixth Sense and 2000’s Unbreakable made him one of Hollywood’s most bankable and distinctive genre movie auteurs, Shyamalan’s recent overcooked, exposition-heavy films have taken a bad turn toward self-important silliness, like a cross between Vincent Price and Paul Harvey. Shyamalan’s output in the past decade — 2006’s Lady in the Water, 2008’s The Happening, 2010’s The Last Airbender, and 2013’s After Earth — amounts to arguably the worst artistic drop-off for an A-list director ever. (Shyamalan’s next film, The Visit, is due in September.)

Nevertheless, Shyamalan and Wayward Pines are a natural fit. Pines is vaguely reminiscent of Shyamalan’s last decent film, 2004’s The Village, the one about a secluded 19th-century community terrified of mythical monsters. Given that Shyamalan had never done television, Hodge thought landing him was a long shot. But a storyteller synonymous with surprise endings agreed to come onboard the day after Hodge sent him the script.

There was just one condition for Shyamalan’s involvement, Hodge said.

“He said, ‘[I’ll do it] as long as the reveal isn’t that they’re all dead.’”

♦♦♦

Ed Araquel/FOX

Is Wayward Pines any good? Having seen half of the show, I can answer 50 percent of this question.

Tonally, Wayward Pines is a little, well, wayward. It’s not always funny when it’s trying to be — the schlocky Americana of the setting is borrowed from countless “eccentric” rural thrillers. At times, Pines is funny in ways that don’t seem wholly intentional: Melissa Leo was clearly encouraged to chew on the wood-paneled, taxidermy-covered scenery as a dastardly nurse with a penchant for public executions. But Terrence Howard’s turn as an ice-cream-loving sheriff is weirdly comic in the same way that everything Howard does now is weirdly comic; his daffy aura transforms each line into a discomfiting Oscar flub. In a cast loaded with reliable ringers — Toby Jones, Hope Davis, Carla Gugino, Shannyn Sossamon, Reed Diamond — tasked with channeling their inner kook, the most surprising twist is that Juliette Lewis (as a local bartender who aids Dillon in his attempts to flee) is the most normal person of the bunch.

The pleasure of watching Wayward Pines’s first five episodes is similar to that of a long-winded joke that wanders far afield before arriving at a punch line. New plot threads come and go like city buses. Characters you think will be essential are suddenly killed off and replaced by new characters you can’t get a read on. Something amazing and preposterous will happen in one scene, and then go seemingly unacknowledged in the next.

Not everyone finds this sort of thing pleasurable: As a real-time barometer of audience reactions, social media shows that some people hate even a moment of ambiguity in their entertainment. At least Pines, unlike Shyamalan’s films, is briskly paced. It’s not always comprehensible, at least not immediately, but Wayward Pines is compulsive viewing regardless.

The 50 percent I can’t speak to is whether any of this pays off. During our phone conversation a few weeks ago, Hodge was determined to sell me on the ending. The fifth episode concludes with a big reveal that sets the show’s second half in motion, which culminates with an even more incredible revelation, he promised.

Now that shows are expected to have fully realized conclusions — rather than just ending via a silent offseason network decree — there’s pressure to either tend to all significant loose ends in a conventionally satisfying way (à la Breaking Bad), or deliberately not tie up loose ends in a manner that will be more fun to think about and discuss for years afterward (like The Sopranos). For Wayward Pines, a show with more than a little Lost in its DNA, Hodge knows that the public will ultimately judge him on how credible the landing is.

“One of the main reasons I wanted to do this is because the show does answer those questions satisfactorily — beyond satisfactorily,” he said. “I can’t think of a show that sets up questions like this show does and then answers them with such a wallop of a reveal. It actually explains everything. I think people are going to really dig it.”

♦♦♦

Lynch/Frost Productions

A frequent point of comparison for Wayward Pines is the early-’90s two-season wonder Twin Peaks. Hodge and De Line have tried to distance Pines from Peaks, but Fox’s own promotional materials play up the connection. Perhaps this is intended to position Pines as a potential Peaks-like phenomenon, though the similarities don’t extend beyond the superficial — there’s a timber-themed title, a Northwestern setting, a clean-cut lawman, and a quirky receptionist at the sheriff’s office. But that’s about it. Philosophically, the shows reside in entirely different batshit zip codes.

Twin Peaks briefly took over American pop culture because viewers were riveted by a rather typical TV-like question — “Who killed Laura Palmer?” was the “Who shot J.R.?” of the George H.W. Bush years. The creators of Twin Peaks, David Lynch and Mark Frost, differed on how to “solve” the mystery. Lynch preferred to leave it open-ended; Frost felt they were compelled to give the audience an answer, a viewpoint supported by ABC. Strangely, ABC wanted Laura Palmer’s killer to be revealed and brought to justice in the middle of the second season, and Lynch and Frost obliged with one of the most emotionally overpowering sequences of the entire series. Then came 13 more episodes with no discernible reason to exist.

Frost won the battle over Laura’s killer, but Lynch came out ahead in the war to keep Twin Peaks weird. The last episode, “Beyond Life and Death,” concludes with Agent Dale Cooper venturing into the Black Lodge in pursuit of the villainous Windom Earle and then becoming possessed by the evil spirit of BOB, the demon that occupied Laura Palmer’s killer, Leland Palmer. The credits roll as the “bad” Cooper cackles menacingly into the camera.

A lot of people hated how Twin Peaks wrapped, including Crouch, who was in middle school when the show aired. “After Twin Peaks ended, I was pretty upset,” Crouch said in an email. “So I started writing a story that picked up right where that final episode left off. I was only 13 or 14, but I still have those pages, printed out on a dot matrix printer from back in the day, buried in a drawer somewhere.”

It would be reductive to describe Wayward Pines as “Twin Peaks with more narrative discipline,” but in a sense that was Crouch’s starting point when he wrote Pines.

“The way I look at it is, in Twin Peaks, the characters act strange because they’re in a David Lynch thing,” Crouch said. “In Wayward Pines, the characters act strange for a very specific, grounded reason that will be explained the further into the books and the show you get.”

When Roger Ebert reviewed 2001: A Space Odyssey in 1968, he paraphrased a quote from an E.E. Cummings poem: “I’d rather learn from one bird how to sing than teach ten thousand stars how not to dance.” Ebert brought up Cummings again when he wrote about 2001’s more straightforward sequel, 2010, 16 years later. The implication was that the first film was a singing bird, and the second film was a sky full of stars not dancing.

If Wayward Pines winds up in a “very specific, grounded” place as promised, I suspect I’ll yearn for the loopy what-the-fuckness of the early episodes. Having all your questions answered satisfactorily — beyond satisfactorily, even — can be overrated. Of course, I heard a bird sing when Agent Cooper saw BOB in the mirror.