Evolution of Cooperation in Social Dilemmas with Assortative Interactions

Cooperation in social dilemmas plays a pivotal role in the formation of systems at all levels of complexity, from replicating molecules to multi-cellular organisms to human and animal societies. In spite of its ubiquity, the origin and stability of cooperation pose an evolutionary conundrum, since cooperation, though beneficial to others, is costly to the individual cooperator. Thus natural selection would be expected to favor selfish behavior in which individuals reap the benefits of cooperation without bearing the costs of cooperating themselves. Many proximate mechanisms have been proposed to account for the origin and maintenance of cooperation, including kin selection, direct reciprocity, indirect reciprocity, and evolution in structured populations. Despite the apparent diversity of these approaches they all share a unified underlying logic: namely, each mechanism results in assortative interactions in which individuals using the same strategy interact with a higher probability than they would at random. Here we study the evolution of cooperation in both discrete strategy and continuous strategy social dilemmas with assortative interactions. For the sake of tractability, assortativity is modeled by an individual interacting with another of the same type with probability r and interacting with a random individual in the population with probability 1− r, where r is a parameter that characterizes the degree of assortativity in the system. For discrete strategy social dilemmas we use both a generalization of replicator dynamics and individual-based simulations to elucidate the donation, snowdrift, and sculling games with assortative interactions, and determine the analogs of Hamilton’s rule, which govern the evolution of cooperation in these games. For continuous strategy social dilemmas we employ both a generalization of deterministic adaptive dynamics and individual-based simulations to study the donation, snowdrift, and tragedy of the commons games, and determine the effect of assortativity on the emergence and stability of cooperation.


Introduction
The evolution and stability of cooperative behavior in social dilemmas is a key aspect of the formation of biological systems at multiple levels of complexity, ranging from replicating molecules, at the lower level, to multi-cellular organisms, at the mid level, to human societies, at the high level.Some examples of cooperation in social dilemmas include: formation of early replicating molecules to form larger replicating systems capable of enhanced information encoding [1,2]; integration of the originally autarchic prokaryote precursors of mitochondria and chloroplasts into eukaryotic cells [2]; differential production of replication enzymes in an RNA phage [3]; blood meal donation to roost mates by vampire bats [4]; predator inspection in fish [5]; allogrooming in social mammals [6]; alarm calls in response to danger by mammals and birds [7]; contribution to a wide variety of public goods [8], including, social security, health and welfare programs; restraint in consuming common pool resources [9,10], such as responsible use of fishing stocks, limiting the emission of pollution into the atmosphere, and sharing Internet bandwidth; correct implementation of the Transmission Control Protocol (TCP) so as to avoid congestion in Internet traffic [11]; and file sharing over peer-to-peer networks [12].
Despite the widespread emergence of cooperation in social dilemmas it has proved to be fundamentally challenging to achieve a satisfactory understanding of the origin and maintenance of this phenomenon [2,[13][14][15][16][17][18].The difficulty in achieving such an understanding is a direct consequence of the nature of a social dilemma itself.A social dilemma may be defined, in classical game theory, as a game which possesses at least one socially inefficient Nash equilibrium [16,19], and in evolutionary game theory, as a game that possesses at least one socially inefficient evolutionary attractor, such as an evolutionary stable strategy [20,21], a stable equilibrium point of the replicator dynamics [22,23], a convergent stable singular strategy of the adaptive dynamics [24][25][26][27], or an attracting state in stochastic evolutionary dynamics [28][29][30][31][32][33].Since in a social dilemma adopting the strategy at the socially inefficient equilibrium or attractor constitutes defection, while adopting the socially efficient strategy is considered to be cooperation, the nature of the dilemma is that individuals employing strategies corresponding to the socially inefficient attractor will be trapped there by the evolutionary dynamics, despite all individuals being better off if they adopted socially efficient behavior.
As an aside it is interesting to note that many acts of cooperation (when the word cooperation is taken in the literal sense meaning the "process of working together to the same end") may have a direct benefit to the cooperating individual that exceeds the cost (see for example [34]).The emphasis on considering cooperation in social dilemmas in theoretical work is due to this case providing the most challenging theoretical problems, rather than cooperation in social dilemmas being necessarily more common than other forms of cooperation.
A considerable number of different approaches to understanding the evolution of cooperation in social dilemmas have been studied [35].These include: kin selection [13,36], direct reciprocity [14,[37][38][39], indirect reciprocity [40,41], evolution in network structured populations [19,, and evolution in group structured populations [76,77].The underlying logic in all these approaches is that they all result in individuals assorting positively, that is, individuals of the same type interact with a greater probability than they would at random.The fundamental role of assortativity in promoting cooperative behavior was already clearly recognized by Hamilton in his work on inclusive fitness [78].The central position occupied by assortativity in the evolution of cooperation through kin selection was made even more explicit by Grafen in his geometric interpretation of relatedness [79,80].Grafen's interpretation of relatedness in terms of assortativity is also discussed in [81].
Assortativity is clearly also a key feature of many other proximate mechanisms for promoting the evolution of cooperation.For example, in network structured populations [37,[66][67][68][69][70]72,73] and in group structured populations [76,77], the formation of clusters of cooperators results in preferential interactions between cooperators [50].The general role played by assortativity in the evolution of cooperation has also been considered recently in [82].
We should emphasize here that many of the most important challenges in understanding the evolution of cooperation center on identifying the different proximate mechanisms that give rise to the assortativity that results in cooperation.However, it is also important to study the effect of assortativity in its own right on the evolution of cooperation.The most significant reason for studying assortativity in its own right is that if it can be shown that positive assortativity leads to some particular outcome in the evolution of cooperation then that provides a rationale for expecting that that outcome will occur for many different proximate mechanisms for obtaining cooperation.
In the present paper we give a detailed and systematic study of the effect of positive assortative interactions, modeled in the manner originally suggested by [79,80], on the evolution of cooperation in a wide variety of both discrete and continuous strategy social dilemmas.In such a system, an individual interacts with another of the same type with probability r and interacts with a random individual in the population with probability 1 − r (where r is a parameter that characterizes the degree of assortativity in the system).
In this paper we take assortativity to be "positive" in the sense that a given individual has a higher probability of interacting with its own type than would be expected at random.The main reason why we focus here on this case is that most mechanisms through which assortativity naturally emerges result in positive assortativity.Perhaps the paradigm of such a situation is evolutionary dynamics in a spatially structured population.In such a population the spatially local nature of the interaction and reproduction processes typically results in the offspring of an individual being localized in the same region of space, and consequently individuals of the same type will often interact with a higher probability than expected from their frequencies in the total population.Thus, evolutionary dynamics in spatially structured populations often results in positive assortativity.
It would be interesting to also consider the possibility of "negative" assortment, in which a given individual would interact with its own type with a lower probability than expected at random.To allow both positive and negative assortativity in a model would require that the degree of assortativity should be dependent on the strategy adopted by the individual, since an individual with a given strategy clearly cannot assort both positively and negatively.In the case of 2 × 2 games the generalization to also allow negative assortment would be relatively straight forward.However, for finite strategy games with more than two strategies or for continuous strategy games, the models would be considerably more complicated.For example, in the case of a continuous strategy game, it would be necessary to specify an "assortativity kernel" that would describe precisely the amount of positive or negative assortativity that any given strategy experiences.Despite the possible complications that may arise, studying the effects of negative as well as positive assortment seems to be an interesting area for future research.
It should also be noted that a different and important approach to elucidating the general role played by assortative interactions in promoting the evolution of cooperation focuses on the use of Price's equation [83].This approach was first developed by Hamilton [78], and has been more recently studied in [84].
We consider here three discrete strategy social dilemmas: the donation game, the snowdrift game, and the sculling game.The donation game is the fundamental exemplar in the prisoner's dilemma class of games, and provides the basic game theory model for altruism [13,17,18].The snowdrift game is an exemplar of a social dilemma in the hawk-dove class of games [15,18].While games of hawk-dove type have been extensively studied as models of conflicts and contests [20,21,85], the snowdrift game provides an interesting model for certain types of cooperative behavior that differ from pure altruism [15,17].The sculling game, is an exemplar of a social dilemma in the coordination class of games.Games in this class have been widely used as models for conventions [28,29,86], but they have typically received little attention as models of cooperation, although interesting exceptions to this trend are [56,70,87,88].The sculling game, as we define it [19], serves as a model for certain types of cooperative behavior not described by the donation or snowdrift games.
We must emphasize here that there is a very substantial literature on the evolution of cooperation in the prisoner's dilemma with assortative interactions, and we do not claim any great novelty for our results in this case.Equivalent results to those that we have obtained for the discrete donation game can therefore be found in the literature [13,79,80,[89][90][91][92][93][94][95][96][97][98].We have discussed the donation game essentially for completeness and to allow comparison with the more novel cases of the snowdrift game and the sculling game.Furthermore, the interesting work [98] considers some closely related issues.The minimum level of assortativity required to allow cooperation to be stably maintained in the prisoner's dilemma, hawk-dove, and stag hunt games is described in terms of the payoff matrix entries in [98], and this leads to a different formulation of some of the results that we obtain here for the discrete strategy games.
Cooperative behavior is often not discrete in nature.This is true of many of the examples of cooperation given above: for instance, when vampire bats share a blood meal with a roost mate [4].Such situations can be described very naturally using social dilemmas formulated in terms of continuous strategy games.The strategies of individuals in the game represent the level of cooperation, or investment, that they make, and are described by continuous variables.The costs and benefits associated with given investments are represented as continuous functions of the investments.Here we consider three continuous strategy games: the continuous donation game [50,53], in which a cooperative investment made by one individual (the donor or investor) towards another individual (the recipient) benefits the recipient but is costly to the donor; the continuous snowdrift game [26], in which the investment benefits both the donor and the recipient but is also costly to the donor; and the continuous tragedy of the commons game [27], in which the investment-in this context an investment typically represents the level of consumption of a limited common-pool resource, and cooperative behavior correspond to modest levels of consumption-benefits the investor but is also costly to both the investor and the recipient.
For the continuous donation game, just as for the corresponding discrete game, in a well-mixed population cooperation will never evolve: that is, the investments made by individuals in the continuous game will evolve to zero for any cost and benefit functions [50,99].Various mechanisms have been proposed for the emergence and maintenance of cooperative investments in the game including: spatial [50] and network [53] structure, and reciprocal altruism [99].
For the continuous snowdrift game [26] and continuous tragedy of the commons game [27] in a well-mixed population a variety of different evolutionary outcomes are possible, depending on the nature of the cost and benefit functions.For example, for some cost and benefit functions the evolutionary end state of the population consists of all individuals making the same non-zero investment.However, for other cost and benefit functions high and low investing individuals coexist-an outcome termed the "Tragedy of the Commune" [26].In the Tragedy of the Commune there is a two-fold social dilemma-not only does evolutionary dynamics result in socially inefficient behavior, but furthermore it forces an unequal outcome in which some individuals make large investments while others invest little or nothing.
Here we consider the effects of positive assortativity on the evolution of cooperation in the continuous donation game, snowdrift game and tragedy of the commons game.We discuss the consequences of assortative interactions both for the level of cooperation that arises and for the emergence of dimorphic evolutionary end states.Related works consider the evolutionary dynamics of continuous strategy games with interaction structure [34,100,101] and the connection to inclusive fitness theory [98].The interesting work [101] is of particular relevance to our work here in that it considers the effect of relatedness in promoting cooperation in a multi-player version of the continuous snowdrift game.In this work relatedness is introduced in a more general manner to our definition of assortativity: the authors of [101] consider a probability distribution over the number of co-players that are identical-by-descent to a focal individual, and then quantify this assortment distribution based upon the mean and variance of the assortative interactions.
The remainder of this article is organized as follows.In the Models section we formulate the three discrete games in terms of a single cost-to-benefit ratio parameter ρ.We analyze the games using the framework of replicator dynamics generalized to include the degree of assortativity r, and derive mathematical relations (analogs of Hamilton's rule) involving parameters ρ and r that must be satisfied for the evolution of complete cooperation.We also formulate and analyze the three continuous strategy games using the framework of adaptive dynamics generalized to allow for assortative interactions, and derive conditions that determine the effect of assortativity on the stability of cooperation.In the Results section we describe the results of studying the evolution of cooperation in these discrete and continuous strategy games with assortative interactions using an individual-based model, and we compare the results obtained from these simulations with those obtained analytically from the assortative generalizations of replicator dynamics and adaptive dynamics.Finally, in the Discussion section we conclude the article with a discussion of the significance of our results and with some suggestions for further inquiry.

Replicator Dynamics with Assortative Interactions
In general, consider a 2-player game with m pure strategies σ 1 , . . ., σ m and strategy space S = {σ 1 , . . ., σ m }.Let P be a large population of individuals, each of which uses a strategy from S. We define assortative interactions as follows.An assortative interaction among individuals is an interaction that occurs preferentially among individuals of the same type, i.e., such an interaction occurs among individuals of the same type with a greater probability than would occur through random interactions.In the context of game theory, this means that individuals using the same strategy interact with a probability greater than that which would occur with random interactions.The most direct and convenient way to introduce assortative interactions in a population is to specify a parameter r ∈ [0, 1], called the degree of assortativity or simply the assortativity, which is defined as follows: with probability r, an individual interacts with another individual of its own type, and with probability 1 − r, the individual interacts with a randomly chosen individual from the population [79,80].Thus, we say that the population P is assortatively-interacting or assortatively-mixed, with assortativity r, if an individual in P interacts with another individual in P with the same strategy with probability r and with a randomly picked individual in P with probability 1 − r.
Let the payoff to strategy σ i against σ j be denoted by π(σ i , σ j ).In biological evolution π(σ i , σ j ) represents the change in the Darwinian fitness (that is, the change in the expected number of offspring) of an individual using strategy σ i in an interaction with an individual using σ j .In social evolution through imitation dynamics π(σ i , σ j ) measures the utility obtained by an individual using strategy σ i in an interaction with an individual using σ j .At time t, let N(t) be the total size of the population P, and let n i (t) be the number of individuals in P using strategy σ i .The frequency of strategy σ i is defined to be p i (t) = n i (t) N(t) .If p(t) = (p 1 (t), . . ., p m (t)) denotes the vector of frequencies, then the state of the population at time t is given by p(t) ∈ ∆ m , where We now consider how the frequencies of the different strategies σ i change with time in an assortatively-interacting population P, with assortativity r, due to natural selection.The fitness f r i of σ i is the average payoff of σ i , which, from the definition of assortativity, is given by The dynamics of p(t) on ∆ m in an assortatively-interacting population can be determined (in analogy with the non-assortative case [17,18,22,23,102]) as follows.The growth rate of the number of individuals n i using strategy where f r = ∑ j p j f r j is the mean fitness of the strategies in the population.This equation is the analog of the standard replicator equation for an assortatively-interacting population.We shall refer to this equation as the assortative replicator equation with assortativity r, or the r-replicator equation for short.The r-replicator equation is the natural generalization of the standard replicator equation when assortative interactions are included in the manner proposed by [79,80].The r-replicator equation is equivalent to the standard (non-assortative) replicator equation under a transformation of the payoffs.If A = (a ij ), where a ij = π(σ i , σ j ), is the payoff matrix, then it is elementary to verify that the replicator equation with transformed payoff matrix Â = rB + (1 − r)A, where B = (b ij ) is the matrix such that b ij = a ii , is equivalent to the r-replicator equation.Notwithstanding this equivalence, however, we feel that the best way to think about the replicator equation when there are assortative interactions is to consider the assortativity as directly affecting how the fitness is defined, as we have done here, since the change in the fitness is clear and natural, whereas the necessary transformation in the payoffs is less clear.
Grafen did not formulate the r-replicator equation in his work, since it was unnecessary for his aim of studying evolutionary stable strategies with assortative interactions.Equations similar to the r-replicator equation have been considered for assortativity that depends on the frequencies of the strategies by [91] and for different population structures (including those that include relatedness) by [92].
For r = 0, the r-replicator equation reduces to the standard replicator equation for a well-mixed population [17,18,22,23,102]: where f = ∑ j p j f j is the mean fitness of the population.Consider now the case of a symmetric 2 × 2 game, with strategies denoted by C and D, and with payoff matrix π given by where α, β, γ, δ ∈ R. Let p denote the frequency of strategy C in the population, and thus 1 − p is the frequency of strategy D. Now consider a population of assortatively-interacting individuals who are playing this 2 × 2 game.Let r denote the degree of assortativity in the population.The fitnesses f r C and f r D of the strategies C and D, with assortativity, are given by and the average fitness of the population is The evolutionary dynamics of the population, with assortativity, is thus given by the r-replicator equation We note that for r = 0, this equation reduces to the standard replicator equation for a symmetric 2 × 2 game [17,18,22,23,102]): where Here, for simplicity, in the rest of this paper when we discuss discrete strategy games we shall restrict our attention to two-strategy games-however, our analysis of evolutionary dynamics in assortatively-mixed populations can be extended to games with any number of strategies, and this may represent an interesting topic for future study.

Donation Game
The donation game is the fundamental exemplar in the prisoner's dilemma class of games, and provides the basic game theory model for altruism [13,17,18].We must emphasize here that there is significant literature on the evolution of cooperation in the prisoner's dilemma with assortative interactions, and we do not claim any particular originality for our results in this case.We discuss the donation game here essentially for completeness and to allow comparison with the more novel cases of the snowdrift game and the sculling game that follows.Equivalent results to those that we obtain here for the discrete donation game can therefore be found in the literature [13,79,80,[89][90][91][92][93][94][95][96][97][98].
Consider the situation of two individuals, John and Bill, who donate blood to each other, as described in [19].Suppose that the act of donating blood to someone incurs a cost c to the donor but confers a benefit b to the recipient, where b, c ∈ R + and b > c.If we consider donation as the cooperative strategy C and non-donation as the defective strategy D, then the payoff matrix for the donation game is given by [19]: where ρ ∈ (0, 1) is the cost-to-benefit ratio ρ = c b .It follows directly from the rank ordering of the elements of the payoff matrix that the game is in the prisoner's dilemma class of symmetric 2 × 2 games.
The standard replicator Equation (8) gives the evolutionary dynamics for the game without assortative interactions to be ṗ = −p(1 − p)ρ.The equilibrium points for the dynamics are p = 0 and p = 1, the former being asymptotically stable, while the latter is unstable.Thus, a well-mixed population of individuals playing the donation game, starting from an initial frequency p 0 ∈ (0, 1) of cooperators, will evolve towards the all-defector ( p = 0) equilibrium state [19].
Consider now an assortatively-interacting population playing the donation game with the payoff matrix given by (9).Let the degree of assortativity be r.It follows directly from the r-replicator Equation ( 7) that the evolutionary dynamics with assortativity for the population is given by ṗ Figure 1 shows the phase line diagrams and the bifurcation diagram for the game.The system has two equilibria, p = 0 and p = 1.For r < ρ, the equilibrium point p = 0 is asymptotically stable, while the equilibrium point p = 1 is unstable.Thus, a population, starting from an initial frequency p 0 ∈ (0, 1) of cooperators, will evolve towards the stable equilibrium p = 0, representing a state in which all individuals defect.However, a bifurcation occurs at r c = ρ, reversing the stability of the two equilibrium points.Hence, if r > ρ a population starting with any positive frequency of cooperators will evolve towards the stable equilibrium p = 1, representing a state in which all individuals cooperate.A similar inequality is arrived at in [92] for the prisoner's dilemma game that has constant gains from switching (that is, in which fitness effects are additive), with the constant r representing the population structure and ρ the ratio of total costs to total benefits (not including self).

Snowdrift Game
The snowdrift game is an interesting exemplar of a social dilemma in the hawk-dove class of games, and provides a model for certain types of cooperative behavior that differ from pure altruism [15,17,18].Consider the situation described in [19] of two individuals, John and Bill, who are stuck in a car on their way home because the road is blocked by a snowdrift.Let the benefit of getting home be b and the cost of clearing the snow be c, where b, c ∈ R + and b > c.If we consider shoveling as the cooperative strategy C and non-shoveling as the defective strategy D, then the payoff matrix for the snowdrift game is given by [19]: where ρ ∈ (0, 1) is the cost-to-benefit ratio ρ = c b .It follows immediately from the rank ordering of the elements of the payoff matrix that the snowdrift game is in the hawk-dove class of symmetric 2 × 2 games.
In the absence of assortativity, the standard replicator Equation ( 8) gives the evolutionary dynamics for the game to be ṗ The equilibrium points for the dynamics are p = 0 and p = 1, and p . The latter internal equilibrium is asymptotically stable, while the former two boundary equilibria are unstable.Thus, a population of individuals playing the snowdrift game, starting from an initial fraction p 0 ∈ (0, 1) of cooperators, will evolve towards the internal equilibrium state ) in which cooperators and defectors coexist [19].
Consider a population of assortatively-interacting individuals playing the snowdrift game with the payoff matrix given by (11).Let the degree of assortativity be r.The r-replicator Equation (7) gives the evolutionary dynamics with assortativity for the population to be ṗ Figure 2 shows the phase line diagrams and the bifurcation diagram for the game.The system has three equilibria: p = 0 and p = 1 at the boundaries, and a possible internal equilibrium It is easy to verify that if r < r c = ρ 2 then the boundary equilibria are unstable, while there exists an internal equilibrium p which is stable.Thus, if r < r c then a population starting with an initial frequency p 0 ∈ (0, 1) of cooperating individuals will evolve to a state of coexistence determined by the internal equilibrium, in which a fraction p of the population will be cooperators and the remainder will be defectors.A bifurcation occurs at r = r c , in which the equilibrium p passes through the boundary equilibrium p = 1, resulting in a change of stability for the boundary equilibria.For r > r c there no longer exists any internal equilibrium, while the boundary equilibrium p = 0 becomes unstable and the equilibrium p = 1 becomes globally asymptotically stable.Therefore, for r > r c a population starting with any positive initial frequency p 0 of cooperators will evolve to the completely cooperative state determined by the equilibrium p = 1.
For r < r c = ρ 2 , in which case there is a stable internal equilibrium p , it follows from that increasing the assortativity r has the effect of increasing the frequency of cooperators at equilibrium.Similarly, in this case, since ] 2 < 0, increasing the cost-to-benefit ratio ρ decreases the frequency of cooperators at equilibrium.Furthermore, for r > r c = ρ 2 , the population is completely cooperative.Thus, for the snowdrift game, cooperative behavior is promoted in an assortatively-interacting population, and the condition r > ρ 2 governing the transition to complete cooperation is an analog of Hamilton's inequality for the donation game.In related work, the minimal level of assortativity required for cooperation to be stably maintained in hawk-dove games is studied in [98].

Sculling Game
Games in the coordination class have typically received little attention as models of cooperation, although for notable exceptions to this tendency see [56,70,87,88].Here we consider the sculling game [19] as an exemplar of a social dilemma in the coordination class of games, with the aim of using it as a model for certain types of cooperative behavior not described by the donation or snowdrift games.Suppose individuals John and Bill are rowing in a double scull to get to their destination, as described in [19].Let reaching the destination have a value of b 2 to both players, where b ∈ R + , and let the cost of rowing be c ∈ R + to the rower.If we treat rowing as the cooperative strategy C and non-rowing as the defective strategy D, then the payoff matrix for the sculling game is given by [19].
where ρ ∈ ( 1 2 , 3  2 ) is the cost-to-benefit ratio ρ = c b .It follows directly from the rank ordering of the elements of the payoff matrix that the sculling game is in the coordination class of symmetric 2 × 2 games.
Equation (8) gives the evolutionary dynamics for the game to be ṗ The equilibrium points for the dynamics are p = 0, p = 1, and p = ρ − 1 2 .The former two boundary equilibria are asymptotically stable, while the latter internal equilibrium is unstable.Thus, a population of individuals playing the sculling game, starting from an initial fraction p 0 ∈ (0, 1)\{ρ − 1 2 } of cooperators, will evolve towards the all-defector ( p = 0) state if p 0 < ρ − 1 2 , and towards the all-cooperator ( p = 1) state if p 0 > ρ − 1 2 .We note that the equilibrium (C, C) is payoff-dominant over (D, D), for all ρ.Moreover, (C, C) is risk-dominant for ρ ∈ ( 1 2 , 1), while (D, D) is risk-dominant for ρ ∈ (1, 3  2 ).A coordination game in which one of the two equilibria is payoff dominant while the other is risk dominant is a stag hunt game [88].Thus, for ρ ∈ (1, 3  2 ) the sculling game is an exemplar of the stag hunt game [19].
Consider a population of assortatively-interacting individuals playing the sculling game with the payoff matrix (14).Let the degree of assortativity be r.The r-replicator Equation (7) gives that the evolutionary dynamics with assortativity for the population is given by ṗ Figure 3 shows the phase line diagrams and the bifurcation diagram for the game.The system has three equilibria: p = 0 and p = 1 at the boundaries, and a possible internal equilibrium It is straightforward to verify that if r < r c = 2ρ 3 − 1 3 then the boundary equilibria p = 0 and p = 1 are stable, and there exists an unstable interior equilibrium p .Thus, if r < r c = 2ρ 3 − 1 3 then a population starting with an initial frequency p 0 = p of cooperators will evolve to the all-defector state p = 0 if p 0 < p and to the all-cooperator state p = 1 if p 0 > p .It follows from this that, for r < r c , then such a population evolves to the all-defector equilibrium p = 0, while if r > r then the population evolves to the all-cooperator equilibrium p = 1.For example, if a population starts with an initial frequency of cooperators p 0 = 1 2 , then r = ρ − 1, and the population will evolve to all-defection if r < ρ − 1 and to all-cooperation if r > ρ − 1.A bifurcation occurs at r = r c , in which the equilibrium p passes through the boundary equilibrium p = 0, resulting in a change of stability for the boundary equilibria.Consequently, for r > r c there does not exist any internal equilibrium, the boundary equilibrium p = 0 is unstable, and the equilibrium p = 1 is globally asymptotically stable.Thus, if r > r c then a population with any positive initial frequency p 0 of cooperators will evolve to the completely cooperative state p = 1.
For r < r c = 2ρ 3 − 1 3 , in which case there is an unstable internal equilibrium p , it follows from ∂p ∂r = ρ−2 (1−r) 2 < 0 that increasing the assortativity r has the effect of increasing the basin of attraction around p = 1, thus decreasing the value of the initial frequency p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Similarly, in this case, since ∂p ∂ρ = 1  1−r > 0, increasing the cost-to-benefit ratio ρ has the effect of increasing the basin of attraction around p = 0, thus increasing the value of the initial frequency p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Furthermore, for r > r c = 2ρ 3 − 1 3 , the population becomes completely cooperative.Thus, for the sculling game, cooperative behavior is promoted in an assortatively-interacting population, and the condition r > 2ρ 3 − 1 3 governing the transition to complete cooperation is an analog of Hamilton's inequality for the donation game.In related work, the effect of assortativity on the maintenance of cooperation in stag hunt games is considered in [98].

Adaptive Dynamics with Assortative Interactions
Let us now consider the evolutionary dynamics of continuous strategy social dilemmas with assortative interactions, which we model using continuous strategy games in assortatively-interacting populations.We quantify the probability that an individual interacts with another individual of its own type (i.e., in the context of games, the probability that an individual using a given strategy interacts with another individual using the same strategy) by the parameter r ∈ [0, 1], the degree of assortativity, in exactly the same way as discussed above for the case of discrete games.Since the exact equivalent of replicator dynamics for continuous strategy games results in an infinite dimensional dynamical system which is difficult to study analytically, here we will adopt the standard approach of using deterministic, monomorphic, adaptive dynamics to study the evolutionary dynamics of the continuous strategy games [17,[23][24][25][26][27][103][104][105].We will study the evolutionary behavior of continuous games in assortatively-mixed populations analytically using a generalization of standard deterministic adaptive dynamics that accounts for the assortative interactions.
Consider a large assortatively-mixed population of individuals, with assortativity r, playing a continuous game.We assume that the interactions are pairwise, with π(x, y) denoting the payoff to an x-strategist when interacting with a y-strategist.Let the population be initially monomorphic with all individuals using the same resident strategy x.Now consider a small fraction ξ of mutant individuals in the population playing strategy y.The fitnesses f r x and f r y of the x and y strategies are given by The invasion fitness φ r x (y) of the mutant strategy y in the resident strategy x is the per capita growth rate of y when rare, and thus is given by φ r x (y) = lim ξ→0 ξ ξ .It follows from the r-replicator We note that when r = 0, the above equation reduces to which is the standard equation for the invasion fitness of a continuous strategy game in a well-mixed population [26].
The adaptive dynamics of a continuous strategy game in an assortatively-interacting population is determined by the invasion fitness φ r x (y) [17,[23][24][25][26]104].The evolution of the strategy x is governed by the selection gradient D(x) = ∂φ r x ∂y y=x , and the adaptive dynamics of x is determined by the differential equation ẋ = mD(x), where m depends on the population size and on the mutational process at work [106].For a constant population size, m simply scales the time variable, and thus we can set m = 1 without any loss of generality.Equilibrium points of the adaptive dynamics are called singular strategies and are solutions of D(x ) = 0.If no such solutions exist, then the strategy x monotonically increases or decreases under evolution, depending on the sign of D(x).If x exists, it is convergent stable and, hence an attractor for the adaptive dynamics, if dD dx x=x < 0. If this equality is reversed, x is a repeller.Initially, the population will converge to a convergent stable singular point x , but its subsequent evolutionary fate depends on whether x is a maximum or minimum of the invasion fitness φ r x (y).If x is a maximum, i.e., if x ∂y 2 y=x < 0, then x is an evolutionarily stable strategy (ESS), representing an evolutionary end state in which all individuals adopt strategy x .
If, however, > 0, then a population of x -strategists can be invaded by mutant strategies on either side of x .In this case the population undergoes evolutionary branching and splits into two distinct and diverging clusters of strategies.

Continuous Donation Game
Consider the situation of two individuals, John and Bill, who donate blood to each other, as described in the discrete donation game formulated in [19].Let us assume now that the amount of blood donated by each individual can vary.Interactions among pairs of individuals in which the cooperative investment (or donation) is continuously variable, and that made by one individual (the donor) benefits the other individual (the recipient) but is costly to the donor, can be described using the continuous donation (CD) game (also referred to as the continuous prisoner's dilemma game) [50,53,99].
The CD game involves the interaction between two individuals, making investments x and y, respectively, where x, y ∈ R + .An investment x has the following effects: the payoff of the investor (donor) is reduced by C(x), where C is a function that specifies the cost of making the investment, and the payoff of the beneficiary (recipient) is increased by B(x), where B is a function that specifies the benefit resulting from the investment.Therefore, the payoff to an x-investor interacting with a y-investor is given by the relation We shall assume here that there is an upper limit x m on the possible level of investment.We also assume that the cost and benefit functions are smooth and monotonically increasing, satisfy C(0) = B(0) = 0, and B(x) > C(x), for x ∈ (0, x c ), where 0 < x c < x m .This latter assumption is a necessary condition for cooperation to evolve: if it does not hold, then if every individual invests x > 0, then each receives a lower payoff than if each had invested 0.
In a well-mixed population (i.e., without assortativity) the adaptive dynamics of the investment x is given by ẋ = −C (x), and thus since C (x) > 0, for all x, it follows that x evolves to 0, the complete defection state.Hence, the CD game is a social dilemma: evolutionary dynamics results in all individuals making zero investment, with each individual consequently obtaining zero payoff, however, if each individual invested x ∈ (0, x c ), then all individuals would receive a payoff π(x, x) = B(x) − C(x) > 0.
For an assortatively-mixed population of individuals with assortativity r, from Equations ( 18) and ( 20), we can write the invasion fitness φ r x (y) as The adaptive dynamics of the investment x is governed by We note here that under quite general conditions the final evolutionary outcome of the CD game in an assortatively-interacting population is completely determined by the analog of Hamilton's inequality described above.Let us assume first that there is no singular strategy x ∈ (0, x m ).In this case, if r > ρ = C (0) B (0) then it follows from the continuity of D(x) that D(x) > 0, for all x ∈ (0, x m ), and thus x will evolve to the maximally cooperative state x = x m .If, on the other hand, r < ρ = C (0) B (0) then x will evolve to the totally defective state x = 0. Let us now assume that there exists a unique singular strategy x ∈ (0, x m ), which is non-degenerate (i.e., D (x ) = 0).In this case, if r > ρ = C (0) then it follows from the continuity of D(x) that D (x ) < 0, and thus x is convergent stable, and as shown above x is therefore also an ESS.Consequently, the population will evolve to a final state in which all individuals are investing x .If, however, r < ρ = C (0) B (0) then D (x ) > 0, and hence x is a repeller.In this latter case, if the initial state of the population x 0 < x then the population will evolve to the total defection state x = 0, while if x 0 > x then the population will evolve to the maximally cooperative state x = x m .

Linear Cost and Benefit Functions
Suppose the cost and benefit functions are linear functions of the investment x, i.e., suppose C(x) = cx and B(x) = bx, where b > c.Linear cost and benefit functions are interesting because they arise as approximations to more general cost and benefit functions.
From Equation ( 22), ẋ = D(x) = rb − c.Since D(x) is constant, there are no singular strategies for the game, and the evolutionary fate of a mutant strategy is determined solely by the sign of D(x).An initially monomorphic population in which every individual invests an amount x 0 ∈ [0, x m ], will evolve to the maximally cooperative state in which all individuals invest x m if r > ρ = C (0) B (0) = c b .If on the other hand the inequality is reversed, then the population will evolve to the state in which all individuals defect by making zero investment.Note that in this case the condition that governs the evolution of cooperation in the CD game is formally identical to the classical Hamilton's rule [107].

Convex Cost and Concave Benefit Functions
Now we consider the case in which the cost function is convex (i.e., C (x) > 0) and the benefit function is concave (B (x) < 0).There is good evidence that in many situations the benefit function exhibits diminishing returns for sufficiently large levels of investment [108][109][110], and the cost is often well described by a convex quadratic function [111].Thus, as an illustrative example we take the cost and benefit functions to be quadratic functions of the investment x: C The evolution of cooperation is determined by the analog of Hamilton's inequality given above: namely, cooperation will evolve if r > ρ = C (0) B (0) .We now make the interesting observation that ρ = 0 (since C (0) = 0 and B (0) = b 1 > 0) and thus the inequality r > ρ is satisfied for any r > 0. Hence, in this case a non-zero level of cooperation will evolve for any positive degree of assortativity.
We obtain the singular strategy x for the game as We now choose x m = 1, and for simplicity take b 1 = 2b 2 .Therefore, and x ∈ [0, 1].Since rB (x ) − C (x ) = −2b 2 r − 2c 1 < 0, the singular strategy x is convergent stable, and hence also evolutionarily stable.As a result, an initially monomorphic population in which every individual invests any amount x 0 ∈ [0, 1], will evolve to a final state in which all individuals cooperate by investing x given by Equation (24).We note in particular that the completely defective initial state x 0 = 0 will evolve to the cooperative state given by x .Thus, in this case, cooperation will always evolve from the completely defective initial state x 0 = 0 for any non-zero degree of assortativity.Furthermore, since ∂x ∂r = 2c 1 r 2 b 1 (1+ 2c 1 rb 1 ) 2 > 0, the cooperative investment x made in the final state increases with assortativity r.Therefore, assortative interactions provide a powerful mechanism for the origin and maintenance of cooperation in the social dilemma defined by the CD game.

Continuous Snowdrift Game
Consider again the case of two individuals, John and Bill, who are stuck in a car on their way home because the road is blocked by a snowdrift.Let us now assume that the amount of effort invested by each individual in shoveling to clear the snow can vary.Each individual benefits from the total investment that they both make to clear the snow, however, each individual only bears the cost of their own investment.Such interactions among pairs of individuals in which the investment made by each individuals is beneficial to both, but involves a cost only to the investor, can be described using the continuous snowdrift (CSD) game [26].
The CSD game concerns two individuals, making investments x, y ∈ R + , respectively.These investments have the following effects: the payoff of each individual is increased by B(x + y), where B(z) is a function that specifies the benefit to each individual resulting from the total amount of investment made by both participants, and the payoff to the investor, say the x-strategist here, is reduced by C(x), where C(x) is a function that specifies the cost to an individual of making a given investment.Therefore, the payoff π(x, y) to an x-investor interacting with a y-investor is given by We shall again assume that there is an upper limit x m on the possible level of investment, that the cost and benefit functions are smooth and monotonically increasing functions satisfying C(0) = B(0) = 0, and B(x) > C(x), for x ∈ (0, x c ), where 0 < x c < x m .
For an assortatively-mixed population of individuals with assortativity r, from Equations ( 18) and ( 25), we can write the invasion fitness φ r x (y) as The adaptive dynamics of the investment x is governed by = (1 + r)B (2x) − C (x).

Concave Cost and Benefit Functions
We now consider the case in which the cost and benefit functions are concave (C (x) < 0 and B (z) < 0).Saturating benefits are clearly realistic [108][109][110], and decelerating costs are reasonable when the initiation of cooperative acts is more costly than subsequent increases in cooperative investments.Suppose, as an illustrative example, that we take the cost and benefit functions to be quadratic functions, i.e, suppose C( We obtain the singular strategy x for the CSD game as The singular strategy is convergent stable if and a repeller if the inequality is reversed.The singular strategy is an ESS if and an EBP if the inequality is reversed.Similar conditions for the convergence and evolutionary stability of a singular strategy are derived in [101] for a nonlinear public goods game with assortative interactions, in which relatedness is defined as the expected value of a fraction of the group that is identical by descent to the focal individual.Thus, an initially monomorphic population in which every individual is investing x 0 ∈ [0, x m ] will evolve to a final state that crucially depends on the coefficients c 1 , c 2 , b 1 , and b 2 of the cost and benefit functions, and on the assortativity r.If Equation ( 29) is satisfied, then the population initially evolves to a state in which all individuals are investing x -the fate of the population thereafter depends on whether or not Equation ( 30) is satisfied.If it is satisfied, then x is an ESS and the population remains at this end state permanently.Otherwise, x is an EBP and the population splits into two distinct phenotypic clusters, which diverge evolutionarily from each other.If, however, Equation ( 30) is not satisfied, then x is a repeller, and the fate of the population depends on the initial strategy x 0 -if x 0 < x , then the population evolves to the zero-investment state x = 0, while, if x 0 > x , then the population evolves to the maximum-investment state x = x m .We note that ∂x ∂r , and thus if the latter inequality holds then increasing assortativity results in higher levels of cooperation x .For given cost and benefit functions, both the location and the nature of the singular strategy x varies as the degree of assortative interactions r changes.The varying nature of the singular strategy x with r in turn results in very different end-states for the evolutionary dynamics.These end-states are: an evolutionary repeller in which all individuals either invest nothing or invest the maximum possible amount, depending on the initial state of the population; an ESS, in which all individuals invest the same amount, given by the singular strategy x ; or an end-state in which evolutionary branching has occurred, leading to the coexistence of high and low investing individuals.This latter outcome represents a two-fold social dilemma-referred to as the "tragedy of the commune" [26]-not only is the total level of investment socially inefficient, but in addition evolutionary dynamics forces an unequal division in the levels of investment.We observe from Equation ( 30) that increasing assortativity inhibits evolutionary branching in the CSD game.Thus, assortative interactions have a dual action on the evolutionary dynamics of the CSD game-increased assortativity first leads to higher levels of cooperation and second reduces the potential for evolutionary branching, thereby reducing the likelihood of unequal levels of cooperation.

Continuous Tragedy of the Commons Game
Consider the case of two individuals, John and Bill, who jointly use a finite common-pool resource, such as a common fishing ground or shared Internet bandwidth.Each of them benefits from consuming the resource, but the costs incurred are shared among both.Such interactions between pairs of individuals sharing a common-pool resource in which consumption of the resource benefits the consuming individual but is costly to both individuals, can be described using the continuous tragedy of the commons (CTOC) game [27].
The CTOC game involves two individuals, making investment x, y ∈ R + , where in this context, the investment means the level of consumption of a limited common-pool resource, and thus cooperative behavior is identified with lower levels of consumption (i.e., lower levels of investment).The investments have the following effects: the payoff of the investor is increased by B(x), where B(x) is a function that specifies the benefit to an individual obtained from consuming a given amount of the resource, and the payoff of each individual is decreased by C(x + y), where C(z) is a function that specifies the cost to both individuals resulting from a given total level of consumption.Therefore, the payoff π(x, y) to an x-investor interacting with a y-investor is given by π(x, y) = B(x) − C(x + y). ( Again we shall assume that there is an upper limit x m on the possible level of investment, that the cost and benefit functions are smooth and monotonically increasing functions satisfying C(0) = B(0) = 0, and B(x) > C(x), for x ∈ (0, x c ), where 0 < x c < x m .These assumptions simply reflect the fact that the public resource is both finite and valuable to those consuming it.
For an assortatively-mixed population of individuals with assortativity r, from Equations ( 18) and ( 31), we can write the invasion fitness φ r x (y) as The adaptive dynamics of the investment x is governed by

Convex Cost and Sigmoidal Benefit Functions
We now consider the case in which the cost function is convex and the benefit function is sigmoidal.Accelerating costs represent a realistic assumption and are often observed in nature [111].
Benefits are also often accelerating initially and then saturate, resulting in sigmoidal benefit functions [21].Suppose, as an illustrative example of this type of cost and benefit functions, we take the cost function to be a quadratic function and the benefit function to be a cubic function, i.e, suppose C(z) = c 1 z 2 and B To simplify the analysis, we take b 2 = 2b 1 and c 1 = b 1 .We obtain the singular strategy x for the CTOC game as The singular strategy is always convergent stable.Moreover, it is an ESS if and an EBP if the inequality is reversed.Thus, an initially monomorphic population in which every individual is investing x 0 ∈ [0, x m ] will evolve to an end-state that depends crucially on the coefficients c 1 , b 1 , and b 3 of the cost and benefit functions, and on the assortativity r.The population first evolves to a state in which all individuals are investing x , and the subsequent fate of the population depends on whether or not Equation ( 35) is satisfied.If it is satisfied, then x is an ESS, and the population remains in this state permanently.Otherwise, x is an EBP and the population splits into two distinct and diverging phenotypic clusters.
We note that ∂x ∂r = 4b 1 ( < 1, and thus if the latter inequality holds then increasing assortativity results in higher levels of cooperation, i.e, lower values of x .For given cost and benefit functions, the location and the type of the singular strategy x varies as the degree of assortative interactions r varies.Thus, as the degree of assortative interactions r changes, so does the form of the evolutionary dynamics.The end-state of the evolutionary dynamics can be either an ESS in which all individuals consume the same amount x of the common resource, or it can be an end-state in which evolutionary branching has taken place, resulting in the coexistence of high and low consuming individuals.This latter outcome represents a second tragedy of the commons-not only is the resource over consumed to the detriment of all, but evolutionary dynamics forces an unequal division degree of consumption.We observe from Equation ( 35) that increasing assortativity inhibits evolutionary branching in the CTOC game.Thus, just as in the case of the CSD game, assortative interactions have a double action on the evolutionary dynamics of the CTOC game, with increased assortativity resulting both in higher levels of cooperation and in a reduced likelihood of unequal levels of consumption.

Individual-Based Model
An individual-based model (IBM), or agent-based model [112], provides a natural alternative method of studying the evolutionary dynamics of a population with assortative interactions, which is complementary to the deterministic approaches discussed above.

Discrete Games
We assume here that the individuals in the population play a symmetric 2 × 2 game with the payoff matrix given by Equation (4).We consider a population of n individuals, with an initial strategy profile s 0 = {s 0 1 , s 0 2 , . . ., s 0 n } at generation 0, where s 0 i ∈ {C, D}, for 1 ≤ i ≤ n.Each generation of the evolutionary dynamics consists of an asynchronous interaction/update round, which involves sampling the population n times with replacement.
Each interaction/update step at generation t is carried out as follows: in the interaction phase we pick uniformly at random two individuals i and j from the population.The two individuals i and j interact (i.e., play the symmetric 2 × 2 game) with individuals k = i and l = j respectively.The interactions are assortative, i.e., with probability r, the individual k (respectively l) is of the same strategy type as i (respectively j), and with probability 1 − r, the individual k (respectively l) is chosen uniformly at random from the population.The change of individual i's strategy from one generation to the next is determined by the payoff that player i receives from interacting with player k and the payoff that player j receives from interacting with player l.Precisely, if s t−1 i , s t−1 j , s t−1 k , and s t−1 l denote the strategies of i, j, k, and l, respectively, in generation t − 1, then in generation t the payoff P i received by individual i is π(s t−1 i , s t−1 k ) and the payoff P j received by individual j is π(s t−1 j , s t−1 l ), where π is the payoff matrix for the game under consideration.In the update phase the probability that the focal individual i will inherit j's strategy, p i←j , is determined using the Fermi update rule as [19] where the parameter β > 0 is the "selection strength" of the update rule.We note that the results of the individual-based simulations described in the next section are robust to changes in the update rule.For example, in addition to employing the Fermi update rule given by Equation ( 36), we have also simulated the individual-based model using the replicator update rule, in which the probability p i←j that the focal individual i inherits individual j's strategy is given by [19] where P max = max(P 1 , P 2 , . . ., P n ), and P min = min(P 1 , P 2 , . . ., P n ).We find that the evolutionary dynamics of the symmetric 2 × 2 games that we study is essentially identical irrespective of which of these update rules we employ.The results presented in the next section arise from simulations using the Fermi update rule (Equation ( 36)).

Continuous Games
An IBM also provides a natural way of studying the evolutionary dynamics of a population playing a pairwise continuous game with assortative interactions.
We again consider a population of n individuals, now with an initial monomorphic strategy profile x 0 = {x 0 1 , x 0 2 , . . ., x 0 n } in generation 0, where Thus in generation t = 0, every individual in the population uses the strategy x 0 .The interactions/update rounds are carried out in the same manner as in the case of discrete games, but with the following additional step: if during the update round at generation t, the focal individual i would have inherited the strategy x t−1 j of the individual j, then with probability µ it instead inherits a mutation of this strategy, picked from a normal distribution with mean x t−1 j and standard deviation σ.If the strategy space is a finite interval [a, b] then the mutations are taken from a truncated normal distribution on [a, b].We note here that changing the precise way in which the random numbers are generated does not effect the outcome of the adaptive dynamics.For example, it was shown in [113] that including random numbers that are uniformly distributed in addition to having random numbers taken from a truncated normal distribution does not significantly change the evolutionary dynamics of the system considered in that paper.
The simulation results presented in the section below are based on the Fermi update rule given by Equation (36).We have also simulated the IBM using the replicator update rule (Equation ( 37)), and have found the results obtained using both rules to be qualitatively identical.

Discrete Games
In this subsection we present the main results of simulations using the IBM introduced above for the donation, snowdrift, and sculling games.Additional results can be found in the Supplementary Materials document.

Donation Game
Figure 4a,b, respectively, show how the analytically predicted and simulated values of p ∞ vary with the assortativity r ∈ [0, 1] and the cost-to-benefit ratio ρ ∈ (0, 1). Figure 4c shows how p ∞ varies with r when ρ = 0.25 and Figure 4d shows how p ∞ varies with ρ when r = 0.25.The results are in excellent agreement with the analysis given above, showing that a population of individuals playing the donation game will evolve to the all-cooperator state (p ∞ = 1) if r > ρ and to the all-defector state (p ∞ = 0) if the inequality is reversed.

Snowdrift Game
Figure 5a,b, respectively, show how the analytically predicted and simulated values of p ∞ vary with the assortativity r ∈ [0, 1] and the cost-to-benefit ratio ρ ∈ (0, 1). Figure 5c shows how p ∞ varies with r when ρ = 0.75 and Figure 5d shows how p ∞ varies with ρ when r = 0.25.The results agree very well with the analysis, which indicates that in a population of individuals playing the snowdrift game, increasing the assortativity r has the effect of increasing the fraction of cooperators at equilibrium, while increasing the cost-to-benefit ratio ρ has the effect of decreasing the fraction of cooperators at equilibrium.Thus, cooperation is promoted by increasing assortativity r, with a transition to complete cooperation occurring when r > ρ 2 .

Sculling Game
Figure 6a,b respectively show how the predicted and simulated values of p ∞ vary with assortativity r ∈ [0, 1] and cost-to-benefit ratio ρ ∈ ( 1 2 , 3 2 ). Figure 6c shows how p ∞ varies with r when ρ = 1.2 and Figure 6d shows how p ∞ varies with ρ when r = 0.25.The results are in very good agreement with the analysis, which indicates that in a population of individuals playing the sculling game, increasing the assortativity r has the effect of increasing the basin of attraction around p = 1, thus decreasing the value of the initial fraction p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Contrarily, increasing the cost-to-benefit ratio ρ has the effect of increasing the basin of attraction around p = 0, thus increasing the value of the initial fraction p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Thus, cooperation is promoted by increasing assortativity r, with a transition to complete cooperation occurring when r > 2ρ

Continuous Games
In this subsection we present the main results of simulations using the IBM introduced above for the continuous donation (CD), continuous snowdrift (CSD), and continuous tragedy of the commons (CTOC) games.Additional results can be found in the Supplementary Materials document.

Continuous Donation Game
We first consider the CD game with linear cost and benefit functions C(x) = cx and B(x) = bx, where b > c.We denote the ratio c b by ρ and refer to it as the cost-to-benefit ratio.The condition r > ρ that promotes cooperative investments, where r is the degree of assortativity, is similar to the one for the discrete donation game, and hence we study the CD game using a similar set of plots.
Figure 7a,b, respectively, show how the analytically predicted and simulated values of the long-term mean strategy x∞ (taken over the last 10% of the generations) varies with the assortativity r ∈ [0, 1] and the cost-to-benefit ratio ρ ∈ (0, 1). Figure 7c shows how x∞ varies with r when ρ = 0.26 and Figure 7d shows how x ∞ varies with ρ when r = 0.26.The results are in excellent agreement with the analysis, which shows that in a population of individuals playing the CD game with linear cost and benefit functions, individuals will asymptotically invest the maximum amount x m if r > ρ and make zero investment if the inequality is reversed.

Continuous Snowdrift Game
The next game we consider is the CSD game with quadratic cost and benefit functions C The singular strategy for the game, given by Equation ( 28), is convergent stable if the inequality given by Equation ( 29) is satisfied and a repeller if the inequality is reversed.On the other hand, the singular strategy is an ESS if the inequality given by Equation ( 30) is satisfied and an EBP otherwise.
Figure 9a,b show the variation of the distribution of the asymptotic strategy values x ∞ (taken over the last 10% of the generations) with assortativity r.The dotted line indicates the singular strategy x .The value of r in (a) at which the singular strategy transitions from an EBP to an ESS is determined by equating the two sides of Equation ( 30) and solving for r.For the given choice of parameters, the transition point (indicated by the dashed vertical line) is r = 0.2.Similarly, the value of r in (b) where the singular strategy changes from a repeller where every individual makes zero asymptotic investment to one in which all individuals make the maximum asymptotic investment x m can be obtained from Equation (29).For the given choice of parameters, the transition point (indicated by the dashed vertical line) is r = 0.13.The results are in very good agreement with the analysis, which shows that in a population of individuals playing the CSD game with quadratic cost and benefit functions, for suitable values of the coefficients, the singular strategy can change from an EBP to an ESS as the assortativity increases.Similar results are presented in [101] for a nonlinear public goods game with assortative interactions, in which evolutionary attractors increase with relatedness (defined as the expected value of a fraction of the group that is identical by descent to the focal individual) while evolutionary repellers decrease with relatedness.34), and is an ESS if the inequality given by Equation ( 35) is satisfied and an EBP otherwise.
Figure 10 shows the variation of the distribution of asymptotic strategy values x ∞ (taken over the last 10% of the generations) with assortativity r.The dotted line indicates the singular strategy x .The value of r at which the singular strategy transitions from an EBP to an ESS is obtained by equating the two sides of Equation ( 35) and solving for r.For the given choice of parameters, the transition point (indicated by the dashed vertical line) is r = 0.3.The results are in excellent agreement with the analysis, which show that in a population of individuals playing the CTOC game with quadratic cost and cubic benefit functions, for suitable values of the coefficients, the singular strategy can transition from an EBP to an ESS with increasing assortativity.

Discussion
In this work we have undertaken a detailed and systematic investigation of the evolution of cooperation in a wide variety of both discrete strategy and continuous strategy social dilemmas with assortative interactions modeled in the manner proposed by [79,80].For the discrete strategy social dilemmas that we have studied-the donation, snowdrift and sculling games-we find that in all cases the frequency of cooperation increases with increasing assortativity.In these social dilemmas the transition to complete cooperation is governed by Hamilton's rule for the donation game, and natural analogs of it for the snowdrift and sculling games.Thus, the entire population evolves to cooperators in the donation game if r > ρ, in the snowdrift game if r > ρ 2 , and in the sculling game (where p 0 is the initial frequency of cooperators).The results for the donation game are essentially well-known [13,79,80,[89][90][91][92][93][94][95][96][97][98], while the results for the snowdrift and sculling games are more novel.Interesting related work is [98], which studies the effect of relatedness on the maintenance of cooperation in prisoner's dilemma, hawk-dove, and stag hunt games.The definition of assortativity and of the games considered in [98] are formulated differently from those adopted here, and we hope that our results may be complementary to those of [98].These results apply quite directly to games between relatives due to the fact that Grafen's geometric interpretation of relatedness allows the degree of assortativity r to be identified with the degree of relatedness between the interacting individuals [79,80].Thus, our results indicate that the emergence of complete cooperation in populations of related individuals playing the snowdrift and sculling games should be governed by the variants of Hamilton's rule described above.
Our results also elucidate the evolution of cooperation in discrete strategy social dilemmas on networks, since evolutionary dynamics in structured populations can result in assortative interactions between the individuals.For example, consider the results obtained for the evolution of cooperation in the donation, snowdrift and sculling games on networks in [19].Comparing the condition found in [19] for complete cooperation to occur in the donation game on networks of mean degree k (namely, 1 ρ > k − 1) with the condition obtained here for assortative interactions (r > ρ) suggests that the effective degree of assortativity resulting from network interactions in the framework studied in [19] is r = 1 k−1 .Now taking this value of r and inserting it into the condition obtained here for the evolution of complete cooperation in the snowdrift game (r > ρ 2 ) then gives that the transition to complete cooperation in the snowdrift game on a network of mean degree k should be governed by the rule that complete cooperation prevails if 1 ρ > k−1 2 .This latter rule is consistent with the results found in [19].Similarly, taking the value r = 1 k−1 in the condition derived here for the evolution of cooperation in the sculling game (r > ρ− 1  2 −p 0 3 2 −p 0 , and taking the initial frequency of cooperators to be p 0 = 1 2 as was the case in [19]) gives the condition for cooperation to evolve in the sculling game on networks found in [19]: namely, that cooperation prevails if 1  ρ−1 > k − 1.Thus we find that despite the simple manner in which assortativity has been modeled here, we obtain results which are applicable to much more subtle systems in which assortativity emerges as a complex, self-organized, phenomenon.
For the continuous strategy social dilemmas that we have considered-the continuous donation, continuous snowdrift and continuous tragedy of the commons games-we also find that the level of cooperation increases with increasing assortativity.An additional interesting finding, and perhaps the most significant result that we have obtained, is that the propensity for evolutionary branching to occur in the continuous snowdrift and continuous tragedy of the commons games is reduced as the degree of assortative interactions increases.Thus, assortativity plays a doubly beneficial role in the evolution of cooperation in these games both by increasing the overall level of cooperation and by reducing the likelihood of unequal and unfair outcomes.We conjecture that this inhibiting effect of assortative interactions on evolutionary branching is a general phenomenon that holds for a broader class of evolutionary systems than merely the continuous strategy games that we have considered here.The interesting work [101] has also explored similar topics to those studied in this paper in that it considers the effect of relatedness on cooperation in a multi-player version of the continuous snowdrift game.In [101] relatedness is introduced in a different, and more general, manner to our definition of assortativity, through the consideration of a probability distribution over the number of co-players that are identical-by-descent to a focal individual.Thus, the results obtained in [101] for the evolutionary dynamics of the multi-player continuous snowdrift game include the results we have obtained for the two-player continuous snowdrift game as a special case (the precise connection between the two approaches is that if we take N = 2, Pr(1) = 1 − r and Pr(2) = r in Equation (3) for the invasion fitness in [101] then we obtain an expression that is equivalent to our Equation (26) for the invasion fitness).Of particular interest is the result found in [101] that increased relatedness reduces the possibility of evolutionary branching in the continuous multi-player snowdrift game.Thus, our result that the propensity for evolutionary branching to occur in the continuous snowdrift games decreases as the degree of assortative interactions increases is a special case of the findings of [101].Since our formalism for studying the effect of assortativity on the evolution of cooperation in continuous strategy games is different from that of [101] we hope that these distinct methodologies may prove to be complementary.It would also be most interesting to apply the methods of [101] to study the evolutionary dynamics of the continuous donation and continuous tragedy of the commons games.
Our results for evolutionary branching in the continuous snowdrift and continuous tragedy of the commons games with assortative interactions imply corresponding results for evolutionary branching in these games played between relatives.We expect, therefore, that evolutionary branching in these games will be inhibited as the degree of relatedness between the interacting individuals increases.Again, it is plausible to conjecture that this phenomenon is not restricted only to those games that we have considered here but holds more widely.
Furthermore, we observe that our results on evolutionary branching in the continuous snowdrift and continuous tragedy of the commons games with assortative interactions may have interesting implications for the evolutionary dynamics of these games on networks.Since one would expect the assortativity produced by interactions on a network to increase as the mean degree of the network decreases, it is therefore natural to conjecture that evolutionary branching in the continuous snowdrift and continuous tragedy of the commons games on networks will be inhibited as the mean degree of the network decreases.We have studied the evolutionary dynamics of the continuous snowdrift and continuous tragedy of the commons games on networks through simulations, and have found that evolutionary branching is inhibited on networks of low mean degree, exactly as predicted by our results (a detailed discussion of the effects of network structure on evolutionary branching in these games will be given elsewhere).Again, it is natural to conjecture that such an increase in the inhibition of evolutionary branching on networks of low mean degree may be a general phenomenon applicable to many evolutionary systems.
D) and f D = pπ(D, C) + (1 − p)π(D, D) are the fitnesses of the strategies C and D, respectively, and f = p f C + (1 − p) f D is the mean fitness of the population.

Figure 1 .
Figure 1.Phase line diagrams and the bifurcation diagram for the donation game with assortative interactions.(a) In the phase line diagrams closed circles represent stable equilibrium points, open circles represent unstable equilibrium points, and the curved line connecting equilibrium points indicates the graph of the function on the right-hand side of the r-replicator equation.(b) In the bifurcation diagram solid lines represent stable equilibrium points, dashed lines represent unstable equilibrium points, and arrows indicate the direction of evolutionary change.

Figure 2 .
Figure 2. Phase line diagrams and the bifurcation diagram for the snowdrift game with assortative interactions.(a) In the phase line diagrams closed circles represent stable equilibrium points, open circles represent unstable equilibrium points, and the curved line connecting equilibrium points indicates the graph of the function on the right-hand side of the r-replicator equation.(b) In the bifurcation diagram solid lines represent stable equilibrium points, dashed lines represent unstable equilibrium points, and arrows indicate the direction of evolutionary change.

Figure 3 .
Figure 3. Phase line diagrams and the bifurcation diagram for the sculling game with assortative interactions.(a) In the phase line diagrams closed circles represent stable equilibrium points, open circles represent unstable equilibrium points, and the curved line connecting equilibrium points indicates the graph of the function on the right-hand side of the r-replicator equation.(b) In the bifurcation diagram solid lines represent stable equilibrium points, dashed lines represent unstable equilibrium points, and arrows indicate the direction of evolutionary change.

Figure 6 ., 3 2 )
Figure6a,b respectively show how the predicted and simulated values of p ∞ vary with assortativity r ∈ [0, 1] and cost-to-benefit ratio ρ ∈ ( 1 2 , 3 2 ).Figure6cshows how p ∞ varies with r when ρ = 1.2 and Figure6dshows how p ∞ varies with ρ when r = 0.25.The results are in very good agreement with the analysis, which indicates that in a population of individuals playing the sculling game, increasing the assortativity r has the effect of increasing the basin of attraction around p = 1, thus decreasing the value of the initial fraction p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Contrarily, increasing the cost-to-benefit ratio ρ has the effect of increasing the basin of attraction around p = 0, thus increasing the value of the initial fraction p 0 of cooperators that is needed for the population to evolve to the all-cooperator state.Thus, cooperation is promoted by increasing assortativity r, with a transition to complete cooperation occurring when r > 2ρ 3 − 1 3 .

3. 2 . 3 .
Continuous Tragedy of the Commons Game Finally, we consider the CTOC game with quadratic cost and cubic benefit functions C(x) = c 1 x 2 and B(x) = −b 3 x 3 + b 2 x 2 + b 1 x.If we let b 2 = 2b 1 and c 1 = b 1 , the singular strategy for the game is given by Equation (