Although groups of excessively spiteful or selfish players quickly collapsed, and rigidly fair-minded societies were readily destabilized by influxes of selfish exploiters, the flexible sharers not only proved able to coexist with the spiteful types, but the presence of spitefuls had the salubrious effect of enhancing the rate of fair exchanges among the genials. By the looks of it, Dr. Smead said, “fairness is acting as a defense against spite.”

The results echo other recent research suggesting that human decency and cooperation require a certain degree of so-called altruistic punishment: the willingness of some individuals to punish rule breakers even when the infraction does not directly affect them — challenging the guy who broke into the line behind you, for example.

“It could be that Nietzsche was right about punishment,” Dr. Forber said, “that it originated as spite and only later was turned into a mechanism for maintaining fairness and justice.”

Frank Marlowe, a biological anthropologist at the University of Cambridge, argued that what looks like spiteful behavior in the real world may really be a matter of image-making. He and his colleagues have used the ultimatum and similar games to study barter and exchange in a broad cross-section of non-Western cultures, including foragers, pastoralists and farmers. They found that no matter how hardscrabble the life or how much the players obviously could have used even a sliver of a potential award, game participants would reject a partner’s stingy offer indignantly, an apparent act of spite that left both empty-handed — at least for the moment.

“It’s probably not spiteful when you’re looking at the long term,” Dr. Marlowe said. “If you get the reputation as someone not to mess with and nobody messes with you going forward, then it was well worth the cost.”

Omar Tonsi Eldakar of Nova Southeastern University in Florida has studied the link between cooperative behavior and what he calls selfish punishment. “Why is everyone always assuming that it’s the good guys who are doing the punishing?” he asked. “Selfish individuals have more reason than anyone else to want to get rid of other cheaters.”

The idea of selfish punishment came to him as a biology graduate student who also competed in track and field. “I noticed it over and over again,” he said. “The people who were most vocal against others using performance-enhancing drugs were the ones who were using performance-enhancing drugs.”