Part of the difficulty in writing about Turing, he went on, is that until fairly recently, much of his work was classified. There are no recordings of him, no videotapes, and from childhood on, his nature was always hard to fathom. Turing was notoriously odd and awkward, the kind of person who stuttered, kept his tea mug chained to a radiator and would walk away in the middle of a conversation if it failed to interest him.

At the same time, Mr. Moore noted, Turing was not a doddering, absent-minded professor type. He was a strong personality, and though driven by logic, he was also capable of deep feeling, especially for a boyhood friend whose death he never stopped mourning. And he was unabashed about having a sex life. At his trial, he expressed no remorse and did not contest the facts.

Hugh Whitemore’s 1986 play “Breaking the Code” (based, like “The Imitation Game” on Andrew Hodges’s 1983 Turing biography) features a Turing who is both tragic and endearing, a sort of innocent eccentric. He was played to great acclaim (in London, on Broadway and in a 1996 BBC movie version) by Derek Jacobi, recycling his “I, Claudius” stammer. Mr. Moore’s Turing is from the beginning more of a mystery, to the viewer and perhaps even to himself. Unlike “Breaking the Code,” which in fact deals very little with the actual code breaking, Mr. Moore’s screenplay doesn’t hesitate to plunge Turing into what amounts to an espionage thriller. Historically, there was no single breakthrough moment, as the movie suggests; the Enigma code had to be cracked several times as the Germans kept refining it. But noting that, for the most part, the camera moves only when Turing does — so that the viewer sees the world mainly through his eyes — Mr. Moore insisted that the movie is conceptually faithful to Turing’s experience. “That’s what it would have felt like to him,” he said. “He would have felt he was in a spy thriller.”

Speaking from his home in London, Mr. Cumberbatch talked at length and with unusual feeling about Turing, who in his version is more complicated, less cozy than in Mr. Jacobi’s. At one point, he even demonstrated Turing’s well-known stammer over the phone: not a full-fledged stutter, but something lighter and more rapid: a voice trying to catch up with the mind whirring behind it.

Mr. Cumberbatch, probably best known as the title character in the BBC series “Sherlock,” said that he was wary of being typecast these days in roles about people who were overly clever, but that he eagerly sought the part of Turing. He knew something of the story to begin with, he explained, from seeing “Breaking the Code,” among other things. And when he read Mr. Moore’s script, he found that it was just as good as its reputation. “I thought, ‘My God, how important this story is, how relevant,’ ” he said. “It sounds trite, but it’s a story that highlights how careful we have to be in a world where people seem different. We’re all different.”

In hindsight, several commentators have suggested that Turing’s personality traits probably placed him somewhere on the Asperger’s spectrum. Mr. Cumberbatch, who prepared for the part by talking to Turing’s relatives and some of his colleagues, said he was wary of that label. “The more I researched it, the more I came to think he was just a very brilliant, very sensitive human being,” he said.