The Calculus of Selfishness