In 1971, Stanford psychology professor Philip Zimbardo wondered if he could create a college activity more detrimental than majoring poetry. (I joke.) But he did transform the basement of a university building into a make-believe prison with the intention of monitoring the effects of unearned authority, depersonalisation and how institutional settings can alter “normal” people.

Offering quick money to college students during the summer (when the campus was mostly empty) a random coin flip determined whether the kids would be prisoners or guards. The experiment was supposed to last two weeks but was cancelled after six days due to alarming way the subjects internalized their roles. Potentially more frightening was how Zimbardo himself had been drawn into the pageantry, and had an outsider not poked her nose in, it might have continued to a more tragic end.

Director Kyle Patrick Alvarez deserves all the praise in the world for the way he cranks up this pressure cooker script. The Stanford Prison Experiment begins with giggles but ends in full psychological break. Alvarez shoots in close-up, allowing you to see the slow shift as these characters begin to slide into their new personas. From the comfort of the audience you can say “this would never happen to me,” but the shooting style sells how the claustrophobia and confusion can so easily lead to a break from reality. After what feels like a long amount of time in a typical movie, Alvarez gets a great, uneasy laugh by flashing the words “Day Two” on the screen.

Two of the kids represent different extremes of social science. Michael Angarano, small in stature, turns into “John Wayne”, a possible sadist, once he gets his baton and sunglasses. It’s worth noting that none of the kids said they wanted the responsibility of being a guard. “Nobody likes guards,” was the vibe during pre-screening. Ezra Miller, with his goofy grin, is the first prisoner to push back against the mental cruelty. But since he does not bend, he is soon broken. After a genuine freak-out he is allowed to leave the experiment. Other prisoners who can’t take the pressure may have waited too long – it is implied they have succumbed to their roles so completely they forget they can demand to leave.

Billy Crudup is marvelous as the unknowable Zimbardo. His intentions are ambiguous, but we accept that surely he must be benevolent. After all, he works at Stamford and he and his colleagues keep referring to this as “important work.” In reality, he was commissioned to study prisons by the US Navy, but this fact is left out of the movie. Sitting alone in the dark of his office watching the prison on a video feed he eventually looks more like a sick voyeur than a professor.

I’ve read a lot about this experiment in the past, but unlike with the work of Stanley Milgram I never quite understood how the subjects didn’t just walk away when things got too extreme. Alvarez does a masterful job of showing how, yes, most recognised that what they were doing was fake, but that didn’t make the emotions any less real. This dreamlike discomfort engulfs the film. One outdoor scene in fresh air toward the end of the picture is completely jarring – back in that windowless hallway, it feels like another world.

Nota bene: The Stanford Prison Experiment played at Sundance, and sometimes small changes are made to films in between their festival run and their public debut. There is a coda to this picture that is one of the more tone deaf bits of filmmaking I’ve seen in quite some time. For five minutes, characters address the camera and barf obvious conclusions at you. Just like someone came to Zimbardo and shook him out of the experiment, I hope someone talks sense to Alvarez and gets him to snip or at least amend this unnecessary appendix.