> Would it be an affirmative defense if we had a defendant who said [...] 
Maybe replace it with playing a sort of FPS game then learning you were, in fact, directing a real drone/robot.

I think you just recapitulated the plot of Ender's Game.

Also a subplot in Arrested Development and the movie Toys.