Last winter, the Queen of England granted English computer scientist Alan Turing a posthumous royal pardon. Turing was convicted of “gross indecency” by the British government in 1952, where homosexualilty was illegal until 1967. He committed suicide two years later.

When he died, few knew the extent of Turing’ s contributions to society. “The Imitation Game” which screened at the Philadelphia Film Festival on Saturday night, highlights them.

Benedict Cumberbatch plays Turing, who leads a group of codebreakers at the British Government Code and Cypher School to unlock the German Enigma code during World War II. His work, though it was kept secret until the 1970s, is said to have saved millions of lives and shortened the the war by years.

When his group needs new codebreakers, Turing puts a crossword puzzle in the newspaper to find anyone who can solve it. Joan Clarke, played by Keira Knightley, does. She comes to Bletchley Park, home of the Code and Cypher School, and much to the astonishment of her teammates, she’s just as apt at deciphering codes as they are. When her parents call her home to find a husband (she’s an elderly 25), Turing proposes to her to keep her around, but the two call of their marriage within months, when Turing confesses to her that he’s gay.

The film flashes back and forth between Turing’s childhood at the Sherborne School in England and the investigation that led to his arrest in 1952, meeting in the middle at Bletchley Park. It’s funny at some points and heartbreaking at others, but Cumberbatch’s performance shines through at them all.

Turing is antisocial and obsessed with the machine he’s building to decode German messages, which he names Christopher, after his closest friend at Sherborne who died from tuberculosis before graduating. “Christopher” defies the expectations of Turing’s Bletchley Park team, deciphering the German Enigma code.