A scene from "Stanford Prison Experiment"

To the average onlooker of Tim Talbott’s resume at the time he was commissioned to write “The Stanford Prison Experiment,” you might not think the screenwriter best known at that point for his time on staff at “South Park” would be the ideal choice to write a thriller based on Dr. Phil Zimbardo’s 1971 psychological study, which transformed a group of college kids looking for a few extra bucks into hardened prisoners losing their mind in isolation and prison guards drunk on authority. You’d be wrong, but then again, the film’s producers almost made the same mistake.

“At the time, I was friends with Chris McQuarrie and they really wanted to hire Chris to do this, but they couldn’t afford him,” recalls Talbott of the start of his 13-year journey with the project. “So basically with Chris’s recommendation, telling them that, ‘Look, I’ll come onto this movie as a producer, and Tim’s going to write the script…’ I think they were secretly hoping that I would fail so they’d get Chris for cheap.’”

Long considered one of the best unproduced screenplays in Hollywood, Talbott didn’t disappoint with “The Stanford Prison Experiment,” crafting a unique take on the experiment by resisting the urge to overdramatize a scenario already fraught with tension. And yet even after securing a cast that included Channing Tatum, Jesse Eisenberg and Paul Dano, among others, the timing never seemed to be right, though controversy over such the treatment of prisoners at detention centers such as Guantanamo Bay made the subject more timely than ever.

Such cruel twists of fate haven’t been uncommon for Talbott, whose raucous comedy “Balls Out,” co-written with Malcolm Spellman about an insurance salesman who becomes a hedonist upon discovering there’s no heaven or hell, has also been the stuff of legend in screenwriting circles. (Thankfully, a table read is available to hint at what could’ve been). Yet it was a stroke of luck when Brian Geraghty, an actor who had been enamored of Talbott’s script when it first made the rounds, was talking to Brent Emery, the producer who initially got Dr. Zimbardo’s life rights, in late 2013 about something else entirely and after the subject came up, suggested that his “Easier With Practice” director Kyle Patrick Alvarez might be a good fit.

The taut result, which features Billy Crudup as Dr. Zimbardo, presiding over an impressive cast of up-and-comers including Ezra Miller, Michael Angarano, Tye Sheridan and Johnny Simmons, earned Talbott the Waldo Salt Screenwriting Award at this year’s Sundance Film Festival and a writing credit for a produced film he can finally be proud of. Shortly before the film’s release, he spoke about the many twists and turns it took to get it into production, how reality provided the most dramatic version of this story, and how life hasn’t exactly changed after Sundance.

How did this come about?

Way back in 2002, I had a friend that was working at Maverick Films, which had gotten the life rights to Dr. Zimbardo and the experiment. Before he started working over there, I wrote these scripts for him that he was very happy with and he called me in to talk to me about possibly writing it. My first reaction was, “I don’t believe you could take a normal, everyday, healthy, sane person and get them to believe that they’re in a prison. Who was ever going to believe that a classroom with bars on the door was a prison they couldn’t get out of?” But I was intrigued, so I did some research.

I watched the documentary that Zimbardo had done and was blown away. Up until that point, different companies had been trying to make a movie of this, but their approach was always to try and make the stakes higher — a life-and-death thing, or like a melodrama where one friend was a guard, one friend was a prisoner, and there was a girl on the outside. They were always trying to build in something that didn’t need to be built into this. So I went back to Maverick and basically said, “Look, the story here should be about what actually happened because it’s fascinating, yet most people don’t know about it.” I started writing it in the summer of 2004, and then finished my first draft in January of 2005.

Did the experiment actually have a natural narrative shape to it?

My whole goal was just tell everything that happened that was important in those five days, so I did a lot of research, including watching upwards of 20-25 hours of videotape from the actual experiment and transcribing all of that. I also had access to Zimbardo and to his original materials as this was going on, so I ended up with a first-draft screenplay that was 255 pages long. I was sure I was going to get fired, but I turned it into the director [Chris McQuarrie] that was attached at the time, and he came back to me two days later, and was like, “No, this is the movie. We just can’t ever show the script to anyone. They’ll never get through it.” So in the following 10 days, myself, the director, and his assistant went through the script from top to bottom and managed to cut it down to 120 pages.

In doing so, it revealed this really interesting structure that’s in the true story, but was buried by all of the extraneous stuff that was in my first draft — the whole idea that the protagonist in the movie keeps changing. You go into the movie, and you’re following [prisoner] 8612, and you think, “Oh, he’s the star of the movie. He’s our eyes into this experiment,” then he’s the first one kicked loose. Then you’re scrambling for who’s the next guy, and [you think it’ll be prisoner] 819 and we follow him, and then he breaks. That keeps happening until you get to that one guy who was basically wallpaper for the first half of the movie, and when [the guards] get him to break, that’s when you realize that the experiment is actually the star of the movie. This situation is really what your main character is, which was born out of just editing the real story down to something manageable.

In general, did a lot of the Chris McQuarrie era of the project contribute to what ultimately happened in the Kyle Patrick Alvarez version?

First of all, Chris McQuarrie and Kyle Alvarez are two completely different people with two completely different sensibilities in terms of what they wanted to do with the project. The version that I’d worked on with Chris was demonstrably different. All the events are still the same, but the way into it and some of the characterizations changed. I did two drafts with Kyle, and a lot of that was just removing Chris’s imprint from the script. It’s not like it was bad or anything. It was just a different take on the material.

In the film that you see now, the guts have been there since the beginning. In fact, I went back last night, and I was reading my very first draft of this and was surprised at how much of the dialogue in the film came from my first draft. That said, the movie is entirely Kyle’s at this point. From the very beginning, I was hesitant as to what this movie would look and feel like because it’s a hallway and three classrooms. How do you keep that interesting for two hours? Kyle and our [cinematographer] Jas Shelton managed to make this movie as visually interesting as it is content-wise. They did a fantastic job.

Was it tough to service this many characters and make each of them distinctive?

It almost drove me mad keeping track of numbers and names during the writing of this. There are like 20 different principals in this movie, and there were more in the first draft. Some of the more superfluous characters got cut, but I was very conscious of this from the beginning, to try and give as much weight to the guards as I was giving to the prisoners because both sides of the story, to me, are fascinating. Seeing the final film, I think it worked out pretty well. It is really an ensemble movie, and we’re so lucky to have so many great actors in it that really brought these roles alive.

Because you only have a few brief moments before you actually go into the experiment, was it difficult to figure out what those would be?

Yeah, it was. Also, it was a conscious choice to not really give any backstory to the prisoners or the guards other than their interviews. That was an invention of Kyle’s — not an invention [exactly since] it really happened, but it was his idea to show the investigators interviewing all those people, so you get a sense that these are all average kids. That’s all you need to know going into the movie because they reveal their characters throughout the course of the film, and they become relatively distinct in the way that they react to what’s going on. I always thought that was more interesting. As a fan of movies from the ’70s, where you didn’t get spoonfed exactly where this person came from, who he is and why he does what he does before the movie starts, I think it’s effective in focusing you on these people because they’re all going to change over the course of this movie and it was fun to do. You don’t often get to kind of do that stuff working in television and studio movies.

Although this had been known as a hot script for a long period of time, after it fell apart, were you surprised when it reentered your life?

Oh, absolutely, but the unsung hero in this whole project is one of our producers, Brent Emery, who was the person that I initially met with way back in 2002. He was the one that had gotten Zimbardo’s life rights for Maverick. By 2007, Chris McQuarrie had fallen off because he was off working on “Valkyrie,” and around that same time, Maverick Films went out of business. We found out in the aftermath of that, without any of us knowing about it, they had borrowed a whole lot of money against our script, so there were dozens of people that had a claim to a piece of it because the company defaulted on the money they had borrowed. So Brent spent the following seven years going all around town, negotiating with people to get the movie rights back. Basically, there were 80-plus chain-of-title items that had to be resolved before we had a clear ability to make the script.

At that same time, Kyle had become involved and I had done some work with him [but thought] this isn’t really going to happen because there’s no way we’re going to get the rights to the script back. Then, all of a sudden, I got a call last year saying, “Hey, I think we’re going to make this movie.” We shot the thing in late August and early September and then got into Sundance in late November, and premiered in Sundance in January. Now here it is July, and the movie’s coming out, so it’s been less than a year from when we started shooting until the premiere of the movie. That just doesn’t really happen a whole lot.

Since you primarily work in television now, do you like the film process? Is one more satisfying than the other?

If writers were coming out and trying to make a living writing, TV is the way to go because when you get hired for a TV show, there’s almost a guarantee that your work is going to be produced and you’re going to get a paycheck every week. With features, sometimes you’ll get paid to start, but you’ll get paid to start two months after they hire you, then it’s always slow getting your money. It makes it very difficult. I’ve had some very, very lean years out here where I’ve had to take one job and stretch it across an entire year. The pluses to television are [also] that they’re going to make your work, and that’s satisfying. It’s much more of a collaborative thing. You’re in a room with other people, and one person is guiding the basic story of what’s going on that season, so it’s much more of a functional job and you try and do the best you can within the situation,

That said, my first love was the movies. I would love to be able to do this as my job, but quite frankly, it’s really, really hard to make a living as a feature writer at this point because it’s just been compressed so much. There are just so few jobs and so many people fighting over them. The fulfillment of getting a good film made for me is really, really satisfying, but there’s also something to be said for a steady job and not have to worry about where my next rent check is coming from. For the last three years, I’ve worked on a show called “Chicago Fire,” and I just stopped doing that, but it was a great run.

Has the acclaim for “Stanford Prison Experiment” changed anything? You won the Waldo Salt Award at Sundance, so have different kinds of offers been coming your way?

What’s funny is that, going into Sundance, I didn’t even stay around for the awards because I thought I had no chance in hell of ever winning anything. I was hopeful that the film would win or Kyle would win or there’d be some kind of special award for the actors, but I was actually at home watching the awards on YouTube. I was blown away when I won. I’m glad Kyle was there. He graciously accepted the award for me, and I thought, “Well, wow! Oh, my God. This is like the most prestigious independent screenwriting award you can get. Surely, this is going to open some doors for me.”

The sad reality is that nobody cares. They just don’t. If the film comes out and somehow becomes a huge critical success and generates money for someone, then somebody will care, but getting an award doesn’t mean anything to the people with money, the people that hire. So obviously, it’s a nice thing to have on my resume, but it really hasn’t opened any doors. That might be because nobody’s seen the movie yet, but I was a little disillusioned after that. But it’s a beautiful little award, and it’s nice to have it.

Well, you’ve got a beautiful little movie here, too, so I hope people go to see it.

I think so too, and thank you for that. It’s a bit of a harrowing thing to sit through. I’ve watched it with audiences enough times now that I can predict when people are going to start really being affected by it. We did the screening at the [Writers Guild Theater] a couple nights ago, and every time I’ve screened this movie, the audience has an outsized reaction. When you get any reaction out of an audience, whether it’s laughter or gasps or whatever, I feel like that is indicative of something that’s working, so I feel good about it.

“The Stanford Prison Experiment” opens on July 17th at the IFC Center in New York and the Arclight Hollywood in Los Angeles.