Solving social dilemmas by reasoning about expectations