Summoning all the Sherlockian eccentricity and superciliousness he can muster, Benedict Cumberbatch once again proves the go-to man for bringing vulnerability and warmth to a chilly, slightly off-putting intellectual oddball in “The Imitation Game,” a handsome, if gently smoothed-over portrait of World War II cryptanalyst Alan Turing.

As the acknowledged grandfather of artificial intelligence, Turing helped create the modern-day computer. Even more important, his preternatural puzzle-solving and mathematical skills helped the Allies win World War II when, as part of a project run by Britain’s MI6, Turing invented a machine that cracked Germany’s seemingly unbreakable Enigma code. “The Imitation Game” chronicles Turing’s wartime efforts, its tale of brainy derring-do bookended by a postwar police investigation that revealed his homosexuality and resulted in his chemical castration and, eventually, suicide.

It’s a tragic story made all the more so by the enormity of Turing’s contributions not only to the war effort but to the technological advances of the 20th century. Gracefully directed by Morten Tyldum from a scrupulously accessible script by Graham Moore, “The Imitation Game” locates Turing within a familiar cinematic line of idiosyncratic geniuses (we recently met another in the person of Eddie Redmayne’s Stephen Hawking) whose gaffes and tics mask hidden philosophical wellsprings and primal wounds. In the filmmakers’ telling, Turing’s brilliance is somehow associated with his habit, as a schoolboy, of separating his vegetables into compulsively arranged color-coded piles. “Mother says I’m just an odd duck,” he intones at one point. Those formative years also coincided with his first love, for a schoolmate named Christopher, whose spirit inspires Turing decades later when he constructs the box of whirring cogs, rotors and disks whose steady, metronomic clicks just might save millions of lives.

That Turing himself is a puzzle — and that he finds it so difficult to break the signs and social codes of his colleagues — are just two gentle ironies of “The Imitation Game,” in which the more challenging technical and conceptual details of Turing’s work are given far less emphasis than the emotional tug of his story and the thriller-like race against time with the Germans. Tyldum has assembled an outstanding group of actors to portray the intelligence officials and researchers who joined Turing at storied Bletchley Park during the war, including Keira Knightley as Joan Clarke, Mark Strong as MI6 chief Stewart Menzies, and Matthew Goode and Allen Leech as fellow codebreakers to whom Turing feels unapologetically superior; he even suggests that the entire team be fired, so that he may use their salaries to work more efficiently. (Later, he brings them apples by way of an awkwardly proffered peace offering.)

The person Turing relates to best is Clarke, who as a woman isn’t allowed to see the classified material the men are working with, and whose struggles with sexism subtly mirror Turing’s own with homophobia. They make a poignant pair, each embodying the enormous social cost of irrational biases and hatreds, with Cumberbatch especially giving an otherwise tetchy, annoyingly arrogant character a welcome dose of humanizing sympathy. Viewers may get the sense that “The Imitation Game” leaves Turing’s essential mysteries intact, but they will nonetheless find even the most public contours his story ripe with drama, excitement and deeply affecting resonance.

★ ★ ★

PG-13. At Landmark’s Bethesda Row Cinema, Landmark’s E Street Cinema and Angelika Film Center Mosaic. Contains some sexual references, mature thematic material and historical smoking. 114 minutes.