  Biological and social scientists have long been interested in understanding
how to reconcile individual and collective interests in iterated Prisoner's
Dilemma. Many effective strategies have been proposed, and they are often
categorized into one of two classes, `partners' and `rivals.' More recently,
another class, `friendly rivals,' has been identified in longer-memory strategy
spaces. Friendly rivals qualify as both partners and rivals: They fully
cooperate with themselves, like partners, but never allow their co-players to
earn higher payoffs, like rivals. Although they have appealing theoretical
properties, it is unclear whether they would emerge in evolving population
because most previous works focus on memory-one strategy space, where no
friendly rival strategy exists. To investigate this issue, we have conducted
large-scale evolutionary simulations in well-mixed and group-structured
populations and compared the evolutionary dynamics between memory-one and
memory-three strategy spaces. In a well-mixed population, the memory length
does not make a major difference, and the key factors are the population size
and the benefit of cooperation. Friendly rivals play a minor role because being
a partner or a rival is often good enough in a given environment. It is in a
group-structured population that memory length makes a stark difference: When
memory-three strategies are available, friendly rivals become dominant, and the
cooperation level nearly reaches a maximum, even when the benefit of
cooperation is so low that cooperation would not be achieved in a well-mixed
population. This result highlights the important interaction between group
structure and memory lengths that drive the evolution of cooperation.
