Benedict Cumberbatch is in talks to play the British mathematician and codebreaker Alan Turing in forthcoming biopic The Imitation Game, reports Deadline.

The Sherlock star may step into the shoes of Leonardo DiCaprio, who was frontrunner to play Turing when the film was announced in 2011. The project has the ring of Oscar bait: it is based on a script by first-time screenwriter Graham Moore, which was bought by Warner Bros for a seven-figure sum after making 2011's Black List of the most popular unfilmed screenplays in Hollywood.

Turing was a wartime hero credited with cracking the German Enigma code at Britain's Bletchley Park codebreaking centre, but his life was destroyed by the period's anti-homosexuality laws. Police arrested Turing in 1952 after learning of his sexual relationship with a young Manchester man. He made no denial or defence during his trial and, rather than go to prison, accepted injections of synthetic oestrogen intended to neutralise his libido.

Turing continued to work part-time for GCHQ, the postwar successor to Bletchley Park, but his mental health is said to have suffered, and he was shut out of Britain's security operations as the country's alliance with the US increased over fears of cold war spying. He was found dead by his cleaner in 1954. The coroner's verdict was suicide, though Turing's mother believed he had accidentally ingested cyanide after a chemistry experiment. In 2009 Gordon Brown made a public apology on behalf of the British government for the way Turing was treated.

Cumberbatch is flying high in Hollywood after securing roles as the main villain in Star Trek into Darkness and as the dragon Smaug in Peter Jackson's Hobbit trilogy. He will also play Julian Assange in The Fifth Estate, a film about the WikiLeaks founder's early struggles, and is set for roles in Steve McQueen's highly anticipated Twelve Years a Slave and the film adaptation of Tracy Letts's Pulitzer prize-winning play August: Osage County.

Turing was excised entirely from the best-known recent film about Bletchley Park, 2001's Enigma. Michael Apted's film cast Dougray Scott as Tom Jericho, a character who seemed to have all the qualities of Turing, bar one vital fact: he was not homosexual and romances Kate Winslet's character.