1 Introduction

From social media, to power grid [35] and road systems [23], to mycorrhizae connecting trees [55], networks play a major role in promoting desirable behaviour. They can improve transport of nutrients or goods [62], they can connect long lost friends [63, 67] and they can even make computer systems resilient to attack [20]. In this paper we focus on how social networks affect the emergence of cooperation in games, specifically the Prisoner’s Dilemma. Our analysis will entirely be based on the effects of social influence on cooperative choices, without assuming underlying communication or reputation mechanisms. In doing so, we resolve some of the discrepancies seen in the experimental and theoretical literature by proposing a standardised framework of differential equations to compare against.

The multi-agent systems community has been greatly concerned with social networks and their effect on interaction since its very start. Social network analysis has been used to derive and extract systems of reputation [42, 46], to explain the emergence of cooperation [14, 47] or conventions [1] and to explore mechanisms of ostracism [40]. Networks have also been used as a policy/control tool to prevent polarisation [52], to promote cooperation via partner selection [50, 51] while also being an emergent property out of reciprocity [38].

Dynamic Networks and Cooperation. When the network is formed by self-interested agents engaging in strategic interaction, some desirable global properties, i.e., achieving Pareto-optimal outcomes, can be hindered by the desire to achieve higher payoff for the agents themselves. Cooperation in the context of game-theory may mean contributing to some collective-risk social dilemma (e.g. investments in green energy) to avoid a collective catastrophe, while defection means no contribution at all [56, 60]; in other settings cooperation may mean incurring some kind of cost (e.g. a tax) to receive social services and defecting means tax-avoidance while benefiting from said services [15]. In this paper in particular we focus on the Prisoner’s Dilemma, when the benefits of cooperation are outweighed by those of defection, such that the latter is the individually rational choice.

Social networks however are rarely, if ever, static and instead are constantly changing. This may be due to an increase in user up-take of an online platform [25], mobility in contact networks [28] or indeed, as in this paper, in response to the behaviour of friends. That is, not only does the network structure impact the game, but the game dynamics also impact the topology of the connections. The question becomes what emerges out of such co-evolutionary processes?

Some theoretical results [16] backed by empirical evidence [17] have suggested that networks have little effect on cooperation or contribution [59]. However, these findings have been obtained using static networks, while a positive effect on cooperation was found experimentally in dynamic [43, 65] and temporal [26] networks with some analytic backing [34, 39, 49]. Even static networks were found to improve cooperation in experiments [44], simulations [48] and theory [12, 33, 39], though it seems to be the case that dynamic networks are far more amenable to cooperation than their static counterparts [29].

Time Scales. When partnerships are imposed exogenously the importance of time scales - characteristic lengths of time over which a particular process occurs - is highlighted; when edge activity is “bursty” - i.e. narrow, sudden spikes of activity - cooperation is impeded while intermediate temporality analytically maximises cooperation [26]. Other studies have found a similar Goldilocks zone - maximal gain for an intermediate value(s) of input(s) - in the time scales [54].

Other streams of research, however, have focused on a threshold effect or time scale separation, where above a certain threshold cooperation flourishes, and below it fails. On the one hand, a few experiments have reported no evidence for such a threshold [65], likely due to considering too restricted a span of time scales, specifically the ratio between strategy and tie update rates. On the other hand, other works support the existence of a threshold [22, 43], which are further backed by a slew of theoretic work [34, 39, 49] that have direct analogues in percolation theory [8, 36].

Experiments and Theory The conflict about which qualitative phenomenon occurs partially reflects the variety of often disjoint assumptions, frameworks and foundational concepts in the literature, at least in terms of temporal aspects. There is certainly a disconnect between theory and experiment; the former mostly considers large time evolution [39] or steady-state results [34] while experiments are typically limited to short term studies on the scale of tens of rounds [43, 44, 65]. There is then great variety in partner selection (e.g. random, round-robin, preferential) for experiments or dynamic tie updates for simulations, occurring in different regimes of the ratio between strategic and topological time scales [13, 34, 49].

Moreover, such experiments rarely, if ever, vary the ratio of timescales and as such there is very little empirical data regarding timescale separation. Understanding systematically why theories offer very different predictions, each backed by their own set of experiments, is a crucial task to truly understand cooperation. The core of such a task is to identify where fundamental assumptions align, differ or are compatible in a systematic way that has yet to be undertaken by current research.

Popularity of Cooperators Regardless of the macroscopic phenomena - Goldilocks zone or time scale separation - experimental results have broadly agreed that those who cooperate tend to be more popular than their misbehaving counterparts. This has then informed the theory, including in our work, of how agents connect to one another. When networks are dynamic and ties are at least partly endogenous - that is, individuals choose to break/form ties rather than being enforced by, say, the researcher - subjects rarely break links with a cooperator [43] partially causing them to have higher degree [4]. In fact as cooperators attract preferential attachment [39, 41, 48], they emerge as “leaders” with high payoff [9].

Assortativity for mutually cooperative links arises out of subjects avoiding defectors when connections are formed bilaterally [65] and via unfriending misbehaving neighbours formed unilaterally [10, 43]. Moreover through ostracism [27] and punishment (for example sanctions as a form of costly ostracism [40]), the co-evolutionary process generates networks with scale-free degree distributions, that promote even more cooperation [48], and are heavily clustered [10] around cooperators [45]. Despite these results, the literature has rarely discussed the topology of the networks that form over long periods of time due to these phenomena.

In this paper we show theoretically and illustrate by simulations that a highly-interconnected sub-graph or core of cooperators, collectively working and benefiting one another, forms while being surrounded by parasitic defectors in the periphery, mostly avoiding one another while clinging to cooperators in the core. This structure we dub the cooperator-core defector-periphery (CCDP).

Cooperation without Reputation Although there is solid theoretical and empirical evidence that reputation is an important mechanism for promoting cooperation [7, 30, 31, 37, 46], here we take an alternative approach and look at the emergence of cooperation when reputation or other communication mechanisms are not available or not reliable enough, and simply focus on the effects of imitation strategies and network dynamics on promoting cooperation. We see our results as complementing reputation research, by showing, among others, when cooperation cannot be sustained by imitation and partner selection alone.

1.1 Contribution

We propose an evolutionary game-theory framework, which we call the Cooperative And Networked DYnamic (CANDY) framework, to disentangle the basic assumptions that enable cooperation in dynamic social networks, only relying on basic reality-resembling imitation strategies. CANDY starts with assumptions on agents’ decision-making - how someone decides to cooperate/defect (the imitation strategy) and chooses to befriend/unfriend others (the network evolution) - and produces the resulting average payoff and total number of cooperators. An illustration of the type of results CANDY can produce is given in Fig.  1.

Methodologically, this framework allows for rigorously testing and comparing different assumptions, finding sets of assumptions which are compatible with empirical data and overcome much of the literature heterogeneity. For instance one may suspect the division in whether the ratio of timescales produces a threshold or Goldilocks effect to be due to the differences in assumptions theorists made or in exogenous update rules imposed upon test subjects. Our framework allows the coexistence of such incompatible results by rigorously scrutinising the underlying assumptions.

To illustrate the power of the CANDY framework, we recover the theoretical results [34] for when edges undergo a birth-death process and strategies follow a Moran [32, 61] or Wright-Fisher [21] process. Furthermore, we consider other edge update models (such as cooperator-popularity) and behavioural models (such as conditional cooperation) that capture the assumptions of other research lines, in order to illustrate the qualitative differences that emerge.

Moreover, we provide a nuanced discussion on timescale separation by reproducing both the threshold effect as seen in [22, 34, 39, 43, 49] and a Goldilocks zone for defection; in many cases we suspect such effects are really artefacts of the finite number of rounds occurring. In recovering both phenomena we highlight how sensitive results are to both initial conditions and to the assumptions of the researcher. That is to say, by having slightly different but equally valid assumptions, the qualitative results can be significantly different.

Finally we illustrate how one assumption/observation - that cooperators are more popular - can lead to the emergence of the same core-periphery structure, despite instrumentally different update rules. Such core-periphery structures have been observed in experiments with human subjects [57] and other agent-based models [45, 53], even when edges can only be broken, not formed for agents with multidimensional opinion spaces; there is an intuitive correspondence between our cooperators and defectors to homogeneous and adversarial agents respectively seen in [53].

Fig. 1
figure 1

The evolution of a dynamic network following the extreme popularity update model, wherein cooperators (C) are always befriended, defectors (D) are always unfriended and strategies are fixed. Colours represent the type of edge: CC edges are in green, CD edges in orange and DD edges in red. Agents are initially placed on a random graph generated by the Erdös-Rènyi model with probability \(p=0.2\) then allowed to update every timestep. As \(t\rightarrow \infty \) a core-periphery structure emerges where cooperators inhabit the core and defectors loosely hang on in the periphery. Note that so long as a non-zero number of cooperators \(C>0\) remain any initial condition, under any of the partner-update rules, will eventually stabilise to this type of core-periphery configuration with a core of size C (Color figure online)

1.2 Paper structure

Section 2 presents the mathematical setup, followed by the introduction of the CANDY framework. Section 3 analyses the partner selection mechanics, while Sect. 4 looks at the imitation strategies. Section 5 provides the main results, showing the behaviour of the CANDY framework on key (random) graph models. We then move to the discussion of the findings and some key pointers for future research. In appendix we provide some basic preliminaries on variables, expectations and dynamical systems.

2 Theoretical model

For a simple graph \(G=(V,E)\) of N nodes playing a repeated Prisoner’s Dilemma game, denote the adjacency matrix as \(A = (a_{ij}:i,j\in V)\) and the strategies as a vector \(\varvec{s}=(s_i:i\in V)\), where the binary strategy s can either be 1 (cooperate) or 0 (defect)Footnote 1. A cooperators pays a cost c per neighbour, such that each of her neighbours gains a benefit b. A defector, on the other hand, pays nothing and nothing happens. This payoff structure was chosen to match the predominant games considered in the literature.

From these \(N(N+1)\) local variables we can find global/aggregate variables that are of the most interest. Given A and \(\varvec{s}\) we can find the payoff vector \(\varvec{\pi } = (\pi _i)\) by defining a modified Laplacian using the payoff-structure (bc)

$$\begin{aligned} L' = cK - bA \end{aligned}$$
(1)

where \(K=diag(k_i)\) is the diagonal matrix of degrees. Note we will also be using \(\varvec{k} = (k_i)\) to refer to the vector of degrees. The payoff vector is then related to the strategy vector by a simple transformation

$$\begin{aligned} \varvec{\pi } = -L'\varvec{s} \end{aligned}$$
(2)

of which the average payoff \({\bar{\pi }}\), can be simply found.

$$\begin{aligned} {\bar{\pi }} = \frac{b-c}{N}\varvec{k}\cdot \varvec{s} \end{aligned}$$
(3)

As with most of the evolutionary game theory literature the two main quantities of concern are the fraction or number of cooperators and the average payoff (i.e. payoff per capita). The latter is less often considered, despite the insight it provides into the actual network structure which in turn aids understanding both processes occurring. For reference, therefore, we write below the equations for the total number of cooperators C and the average payoff \({\bar{\pi }}\) in terms of local variables.

$$\begin{aligned} C= & {} \sum _{i\in V} s_i \end{aligned}$$
(4)
$$\begin{aligned} {\bar{\pi }}= & {} \frac{b-c}{N}\sum _{i,j\in V}a_{ij}s_j \end{aligned}$$
(5)

Rather than dealing with strictly discrete variables, we can instead move to the continuum by considering probabilities - here such probabilities are also identically the expectations of binary variables. Specifically we will consider \({\tilde{a}}_{ij}\equiv {\mathbb {P}}(a_{ij}=1)\) and \({\tilde{s}}_i \equiv {\mathbb {P}}(s_i=1)\) as the probabilities for edge (ij) to exist and for node i to cooperate at time t, respectively. We then assume such probabilities evolve due to two independent processes - a vector field acting on the adjacency matrix, \(f_g\), and one acting on the strategy vector \(f_s\). In other words in the joint probability space \([0,1]^{N^2}\times [0,1]^N\) where a point represents an entire state, this point moves due to the ‘velocities’ \(f_g\) and \(f_s\).

As we require products, sums and sums of products of Bernoulli variables and in particular we want expectations of such variables such that we can replace the binary variables with their probabilistic counterparts. As shown by Appendix A, the sum of Bernoulli variables is Poisson Binomial and that the sum of products of Bernoulli variables are also Poisson Binomial. As such we can replace \(s_i\)’s and \(a_{ij}\)’s in Eqs.4 and 5 with the tilde variables.

$$\begin{aligned} {\mathbb {E}}(C)= & {} \sum _{i\in V} {\tilde{s}}_i \end{aligned}$$
(6)
$$\begin{aligned} {\mathbb {E}}({\bar{\pi }})= & {} \frac{b-c}{N}\sum _{i,j\in V}{\tilde{a}}_{ij}{\tilde{s}}_j \end{aligned}$$
(7)

2.1 CANDY framework

In general we can write down \(N(N+1)\) coupled differential equations (DEs) for both success probabilities at time t, in terms of our two vector fields \(f^g = (f^g_{ij}:i,j\in V)\) and strategic process \(f^s=(f^s_i:i\in V)\), which have characteristic time scales \(\tau _g\) and \(\tau _s\) respectively.

$$\begin{aligned} \frac{d{\tilde{a}}_{ij}}{dt} = f_{ij}^g(A,\varvec{s},t;\tau _g) \end{aligned}$$
(8)
$$\begin{aligned} \frac{d{\tilde{s}}_{i}}{dt} = f_i^s(A,\varvec{s},t;\tau _s) \end{aligned}$$
(9)

More often than not it is easier to construct transition rates rather than the full differential equation. Thus let us write \(f^g_{ij}\) and \(f^s_{i}\) in terms of transition rates: given \((i,j)\not \in E\) the rate to form said edge \(g_{ij}(0,1)\); given \((i,j)\in E\) the rate to break the edge \(g_{ij}(1,0)\); given \(s_i=0\) the rate to cooperate \(h_i(0,1)\) and finally given \(s_i=1\) the rate to defect \(h_i(1,0)\).Footnote 2

$$\begin{aligned} f^g_{ij}= & {} g_{ij}(0,1)(1-{\tilde{a}}_{ij}) - g_{ij}(1,0){\tilde{a}}_{ij} \end{aligned}$$
(10)
$$\begin{aligned} f^s_i= & {} h_i(0,1)(1-{\tilde{s}}_i) - h_i(1,0){\tilde{s}}_i \end{aligned}$$
(11)

This provides the basis for the entire Cooperative And Networked DYnamics (CANDY) framework. So long as the update rules have a closed form, the above \(N(N+1)\) equations fully specify the dynamics. CANDY allows for update rules that are time-dependent, parameterised and/or heterogeneous - suffice to say an incredibly broad range of possibilities. Moreover, by integrating the vector fields \(f^g\) and \(f^s\), the flows (see Appendix B for more detail) are fully recovered \(\varPhi = (\varPhi ^g,\varPhi ^s)\) allowing researchers to potentially sidestep lengthy and computationally heavy agent-based simulations.

The evolution of C and \({\bar{\pi }}\) are further gotten by differentiating Eqs. 4 and 5 to get DEs in terms of the generalised processes.

$$\begin{aligned} \frac{dC}{dt}&\equiv F^C = \sum _{i\in V} f^s_i \end{aligned}$$
(12)
$$\begin{aligned} \frac{d{\bar{\pi }}}{dt}&\equiv F^\pi = \frac{b-c}{N}\sum _{i,j\in V} (f^g_{ij}{\tilde{s}}_i + {\tilde{a}}_{ij}f^s_i) \end{aligned}$$
(13)

In specifying the local evolution due to \(f^g\) and \(f^s\), researchers are able to clearly lay out their assumptions, numerically integrate and finally compare predictions. This generative method follows the same approach as much of the agent-based modelling community, but with the added bonus of allowing for comparisons between qualitatively different hypotheses as it provides a standard framework to work within.

In general solving for the two global variables requires local knowledge and solutions may not be analytically tractable. However under certain local processes, \(F^C\) and \(F^\pi \) may be written only in terms of C and \({\bar{\pi }}\) (and generally t), in which case the global behaviour reduces significantly down to a system of 2 coupled DEs, or even a single equation. When analytic solutions do not exist, numerical integration may still provide a computational improvement on pure agent-based simulations, depending on the level of heterogeneity. The more homogeneous the population - and hence the fewer unique coupled equations to solve - the more efficient and accurate a numerical integration method would be.

At worst, for example, if all agents were entirely unique with unique strategies then CANDY would perform as slowly as a complex ABM. Furthermore writing down neat or efficient equations to describe increasingly complex interactions becomes more difficult. However a sufficiently complex ABM would also suffer a similar difficulty when more and more externalities, socio-cognitive factors, etc. are considered.

In the next two sections we look at the two dimensions of the coevolutionary process, that of partner-updates and that of strategy-updates. We treat the two processes as independent, much like the equations of a fluid flow can be broken down into component parts. We illustrate how to arrive at the vector fields \(f^g\) and \(f^s\) by example, deriving \(f^g\) and \(f^s\) for several partner-update (Sect. 3) and strategy-update (Sect. 4) rules.

3 Partner-update rules

In this section we consider a broad range of graph-theoretic models (GMs) of partner updates, in other words how edges change over time. We do so to illustrate the variety of empirical observations and assumptions of relationship building/breaking that are as valid as one another but that may produce entirely different dynamics. In particular we highlight three GMs - an extreme version of empirical observations that cooperators are always popular, an active linking model [34] and exogenously imposed networks as in [26].

In later sections we will combine such models with different behavioural models (see the next section) of how agents choose to cooperate or defect. In so doing we arrive at a diverse set of dynamics, some producing timescale separation while others show regimes of mass cooperation and mass defection.

3.1 Graph-theoretic model 1: extreme popularity

Following empirical results that cooperators are more popular [4, 43, 65], we take the extreme limit where only cooperators are befriended and defectors are entirely unfriended. That is at each time step (discrete round) a pair of nodes \(i,j\ne i \in V\) is randomly chosen. If the alter j is a cooperator, \(s_j=1\), then the ego i will unilaterally form an edge with j if none previously existed. Otherwise if j is a defector, \(s_j=0\), i will unilaterally break ties with j if the edge already existed. Note that by specifying at each time step we have inadvertently set a graph-theoretic timescale \(\tau _g\); in the units of time-steps \(\tau _g=1\) but one could also use units defined by the total number of edges possible - in other words the number of dyads - \(T=N(N-1)/2\).

From this, we can specify the transition rate for an edge (ij) to form \(g_{ij}(0,1)\) or break \(g_{ij}(1,0)\).

$$\begin{aligned} g_{ij}(0,1)&= \frac{1}{\tau _g} \frac{1}{2} \bigg [s_i(1 + s_j) + (1-s_i)s_j\bigg ] \end{aligned}$$
(14)
$$\begin{aligned}&= \frac{1}{\tau _g} \frac{s_i+s_j}{2}\end{aligned}$$
(15)
$$\begin{aligned} g_{ij}(1,0)&= \frac{1}{\tau _g} \frac{1}{2} \bigg [s_i(1-s_j) + (1-s_i)\big [2(1-s_j) + s_j\big ] \bigg ] \end{aligned}$$
(16)
$$\begin{aligned}&= \frac{1}{\tau _g}\big ( 1 - \frac{s_i + s_j}{2}\big ) \end{aligned}$$
(17)

The factor of 1/2 is the probability to choose the active node as the ego, i.e. the one to unilaterally make or break a tie. The first term in Eq. 14 is from if i is a cooperator and j is chosen as ego, j always connects, otherwise if i is chosen as ego then i connects only to another cooperator; the second term is when i is a defector and is the ego, thus can connect to j if j is a cooperator. Similarly, for Eq. 16, the first term comes from when i is a cooperative ego disconnecting to a defector; the latter half is when i is a defector so either if both ij are defectors there’s two ways to break the tie or a cooperator j disconnects to i. Finally the evolution of \({\tilde{a}}_{ij}\) can be found by summing the gain terms and loss terms.

$$\begin{aligned} f^g_{ij}&= \frac{1}{2\tau _g}\bigg [ (s_i+s_j)(1-{\tilde{a}}_{ij}) - (2 - s_i-s_j){\tilde{a}}_{ij}\bigg ] \nonumber \\&= \frac{1}{\tau _g} \bigg [ \frac{s_i+s_j}{2} - {\tilde{a}}_{ij}\bigg ] \end{aligned}$$
(18)

As a sanity check when both i and j cooperate and are connected, \(f^g = 0\) so the edge is stable. Similarly when both are defectors and disconnected \(f^g=0\) so the lack of an edge is stable too. Finally in general, as strategies are not fixed, to compensate for their probabilistic nature, we can simply replace \(s_i\) with \({\tilde{s}}_i\). The utility of having such a kernel is that we can obtain a DE for \(k_i\) - simply sum over all \(j\ne i\), \({\dot{k}}_i = \sum _{j\ne i}f^g_{ij}\) - and by extension a DE for the payoff per capita when strategies are fixed.

3.2 Graph-theoretic model 2: active linking

We consider the active linking model [34] to illustrate how their assumptions lead to a bottom-up or micro-scale model that then lead to the same meso-scale and macro-scale results. In active linking, cooperators and defectors form edges at some constant rate \(\alpha _C\) and \(\alpha _B\) and that different edge types decay away at rates \(\beta _{CC},\beta _{CD}\) and \(\beta _{DD}\) for CCCD and DD edges respectively. Notice unlike our first model, this assumes an agent is not biased towards befriending cooperators over defectors, counter to empirical results. Instead your strategy impacts how strongly you connect to anyone else; in a sense this views relationships as stemming from the individual and not from reputations/biases.

Similarly to extreme popularity we can arrive at the transition rates by considering when i is a cooperator then j is either cooperator or defector and vice-versa. Notice now instead of a single graph-theoretic timescale there are potentially several timescales (edge formation versus edge destruction), but where they are not significantly different one could simply take an average.

$$ \begin{gathered} g_{{ij}} (0,1) = s_{i} s_{j} \alpha _{C}^{2} + (1 - s_{i} )(1 - s_{j} )\alpha _{D}^{2} \hfill \\ \quad \quad \quad + (s_{i} + s_{j} - 2s_{i} s_{j} )\alpha _{C} \alpha _{D} \hfill \\ g_{{ij}} (1,0) = s_{i} s_{j} \beta _{{CC}} + (1 - s_{i} )(1 - s_{j} )\beta _{{DD}} \hfill \\ \quad \quad \quad + (s_{i} + s_{j} - 2s_{i} s_{j} )\beta _{{CD}} \hfill \\ \end{gathered} $$

Substituting the above transition rates into Eq. 10 we get an incredibly long and verbose equation for \(f^g_{ij}\).

$$ \begin{gathered} f_{{ij}}^{g} = s_{i} s_{j} [\alpha _{C}^{2} (1 - \tilde{a}_{{ij}} ) - \beta _{{CC}} \tilde{a}_{{ij}} ] \hfill \\ \quad \quad + (s_{i} + s_{j} - 2s_{i} s_{j} )[\alpha _{C} \alpha _{D} (1 - \tilde{a}_{{ij}} ) - \beta _{{CD}} \tilde{a}_{{ij}} ] \hfill \\ \quad \quad + (1 - s_{i} )(1 - s_{j} )[\alpha _{D}^{2} (1 - \tilde{a}_{{ij}} ) - \beta _{{DD}} \tilde{a}_{{ij}} ] \hfill \\ \end{gathered} $$
(19)

Importantly, each of the three terms above correspond to the three types of possible edges forming and breaking. The first term (\(s_is_j[\cdots ]\)) denotes evolution of CC-edges since \(s_is_j=1\) iff both i and j are cooperators; similarly the other two denote evolution of the CD and DD-edges respectively.

3.3 Graph-theoretic model 3: exogenously imposed networks

Consider when the network is exogenously imposed - perhaps the structure is synthetically produced or reshuffled by the researcher, or as in [26] the network is empirical, such as contact-networks. In this case \(N^2\) equations are eliminated and the only interesting dynamics occurs within the strategic space, as the graph-theoretic space has been fully specified.

For instance in the discrete case, let \(\{t_0,t_1,\cdots \} \in {\mathbb {R}}\) be a sequence of timestamps at which the adjacency matrix has changed so that during each interval \(t_m\le t < t_{m+1}\) the network is fixed. The graph-theoretic timescale can be defined as a statistic on the set of interval periods, for example the mean or the minimum of such a set. When strategies update following an imitate-payoff type rule (see BM1 below) slower than the network gets updated, cooperation is promoted while when \(\tau _s<\tau _g\) mass defection occurs [26].

4 Strategy-update rules

In this section we focus on how agents decide to cooperate or defect, in particular we consider three different mechanisms for the imitation of neighbours. One, when imitation is purely payoff-dependent of a random successful neighbour, similar to [48]. Two, imitation happens due to social pressures that is, presented with a crowd of opinions disagreeing with her, an agent will change her strategy, in other words conditional cooperation [5, 11] which is also known as the voter model [19]. Finally, as a hybrid of the previous two, where both payoff and the will of the crowd matters, the pairwise comparison rule [39].

There are, of course, a multitude of other more complex decision making processes - for example moody conditional cooperation [18] and tag-based cooperation when agents have observable traits [58]. For example imitation strength is reflected in the equations for an individual i’s strategy \({\dot{s}}_i\) and the functional form of \(f^s_i(A,{\mathbf {s}},t;\tau _s)\). However to address every single possible rule would be never-ending. Hence for the sake of a focused scope and for readability we focus only on three.

4.1 Behavioural model 1: imitate-payoff

Here we consider strategies are updated by pure imitation that are discretely payoff-dependent, that is imitation occurs if and only if the proposed alter has a higher payoff. Every \(\zeta \) time-steps, \(\eta \) existing edges are picked randomly.Footnote 3 One node per edge is then chosen randomly to be the ego i, who will imitate the strategy of their partner j iff \(\pi _j > \pi _i\). Measuring in time-steps the strategic timescale is \(\tau _s = \zeta /\eta \), while relative to the timescale due to the graph-theoretic process \(\tau _s= \tau _g(\zeta /\eta )\).

4.2 Behavioural model 2: conditional cooperation

Alternatively to the payoff-dependent model, we can instead consider conditional cooperation (also known as a voter model) [5, 19] where an agent cooperates if their neighbours also cooperate. This is frequency-dependent and payoff-independent, embodying the social pressures to imitate and change strategies (see for example [2, 64, 68]).

Every \(\zeta \) time-steps, \(\eta \) nodes are picked randomly. Such a node i, with strategy \(\sigma \), will switch strategies to \(\sigma ' \ne \sigma \) iff the fraction of their neighbourhood with strategy \(\sigma '\) strictly exceeds a given threshold \(v_{\sigma \sigma '}\). This rule is thus parameterised by two thresholds \({\mathbf {v}}=(v_{cd},v_{dc})\), where \(v_{cd}\) is the for a cooperator to start defecting - that is the minimum fraction of a cooperator’s neighbourhood that are defectors - and similarly for \(v_{dc}\). Since nodes are picked, rather than edges, the most reasonable time unit to consider would be in timesteps hence \(\tau _s=\zeta /\eta \), otherwise when compared to the graph-theoretic process \(\tau _s=\frac{N-1}{2}\frac{\zeta }{\eta }\tau _g\).

4.2.1 Probabilistic version

Rather than having deterministic rules, we let the \(\eta \) nodes update stochastically, depending on the fraction of cooperators (or defectors) in their local neighbourhood. In this treatment, the probability for a defector to cooperate is the fraction of their neighbour who cooperate and vice versa.

$$\begin{aligned} h_i(0,1)&= \frac{1}{\tau _s}\frac{\sum _{j}a_{ij}s_j}{\sum _{j}a_{ij}} \nonumber \\ h_i(1,0)&= \frac{1}{\tau _s}\big (1-\frac{\sum _{j}a_{ij}s_j}{\sum _{j}a_{ij}}\big ) \nonumber \\ f^s_i&= \frac{1}{\tau _s}\bigg (\frac{\sum _{j}a_{ij}s_j}{\sum _{j}a_{ij}} - {\tilde{s}}_i\bigg ) \end{aligned}$$
(20)

Unfortunately due to the denominator, taking the expectation of Eq. 20 does not result in substituting the variables for their probabilities. Consider the first term as a function \(\gamma _i:{\mathcal {A}}\times {\mathcal {S}}\rightarrow {\mathbb {R}}\) acting on the adjacency matrix and the strategy vector. Denote, as usual, the expected values as \({\tilde{A}}=({\tilde{a}}_{ij}:i,j\in V)\) and \(\tilde{\varvec{s}}=({\tilde{s}}_{i}:i\in V)\). We can approximate \(\gamma _i\) with a Taylor expansion.

$$\begin{aligned}&\gamma _i(A,\varvec{s}) =\; \gamma _i({\tilde{A}},\tilde{\varvec{s}}) + \sum _j \bigg [ (a_{ij}-{\tilde{a}}_{ij})\frac{\partial \gamma _i}{\partial a_{ij}} + (s_j-{\tilde{s}}_j)\frac{\partial \gamma _i}{\partial s_j} \bigg ] \\&\quad + \frac{1}{2}\sum _j\bigg [ (a_{ij}-{\tilde{a}}_{ij})^2\frac{\partial ^2 \gamma _i}{\partial a_{ij}^2} + (s_j-{\tilde{s}}_j)^2\frac{\partial ^2 \gamma _i}{\partial s_j^2} \bigg ] \\&\quad + \sum _{j,k}\bigg [(a_{ij}-{\tilde{a}}_{ij})(a_{ik}-{\tilde{a}}_{ik})\frac{\partial ^2 \gamma _i}{\partial a_{ij}a_{ik}} \\&\quad + (s_j-{\tilde{s}}_{j})(s_{k}-{\tilde{s}}_{k})\frac{\partial ^2 \gamma _i}{\partial s_{j}s_{k}} + (a_{ij}-{\tilde{a}}_{ij})(s_{k}-{\tilde{s}}_{k})\frac{\partial ^2 \gamma _i}{\partial a_{ij}s_{k}} \bigg ] +\cdots \end{aligned}$$

Taking the expectation of the Taylor expansion, the first order derivative terms drop away while the higher order terms are now multiplied by variances and covariances; the variance can be explicitly found in terms of the Bernoulli parameters \(Var(a_{ij}) = {\tilde{a}}_{ij}(1-{\tilde{a}}_{ij})\). Any second order derivatives (or higher) with respect to strategies disappear as \(f_i\) are linear in strategies. Finally assuming pointwise independence, covariance terms will vanish, thus leaving an approximate expression for \(f_i\) in terms of only the expected adjacency matrix and strategy vector.

$$\begin{aligned} {\mathbb {E}}[\gamma _i(A,\varvec{s})] \approx \frac{\sum _{j}{\tilde{a}}_{ij}{\tilde{s}}_j}{\sum _{j}{\tilde{a}}_{ij}} + \sum _j \frac{{\tilde{a}}_{ij}(1-{\tilde{a}}_{ij})}{(\sum _{k}{\tilde{a}}_{ik})^2} \bigg (\frac{\sum _{k}{\tilde{a}}_{ik}{\tilde{s}}_k}{\sum _{k}{\tilde{a}}_{ik}} - {\tilde{a}}_{ij}\bigg ) \end{aligned}$$

Noting that the second term and higher order terms are \(O(N^{-2})\) for non sparse graphs, a first order approximation of \(\gamma _i\) is sufficient so we can in fact replace the variables in Eq. 20 with the continuous version.

$$\begin{aligned} f^s_i = \frac{1}{\tau _s}\bigg (\frac{\sum _{j}{\tilde{a}}_{ij}{\tilde{s}}_j}{\sum _{j}{\tilde{a}}_{ij}} - {\tilde{s}}_i\bigg ) +O\big (\frac{1}{N^2}\big ) \end{aligned}$$

4.3 Behavioural model 3: pairwise comparison rule

In Behavioural Model 1 (imitate-payoff) an agent imitates precisely one neighbour based on the pairwise difference in payoffs, following a step-function. In reality someone may copy a friend even if their payoff was worse; for a start there might be some leniency where a friend might earn $10 more but I do not instantly side with him. Moreover, although a single friend may earn more via their alternative strategy, there may be social pressures to stick to my current strategy. Model 2 takes the extreme and assumes the only thing that matters is the number of friends with a given strategy, so that if \(80\%\) of my neighbourhood are cooperators I’m \(80\%\) likely to cooperate.

The birth-death process of [39] takes a hybrid/intermediate stance relative to Models 1 and 2. It assumes that a) payoffs matter for imitation but not as rigidly as a step function - instead it should be smooth and continuous - and b) that social pressures also matter, so that the probability to flip strategies is given by the average probability to imitate an alternative strategy. Explicitly, the probability \(p_{ij}\) for i to imitate the alternative strategy of j, i.e. \(s_i \ne s_j\), follows a sigmoid with parameter \(\beta \) measuring the strength of peer pressure and payoffs acting as the energies. The probability for i to flip strategies is the mean of pairwise \(p_{ij}\) over alternative-strategy neighbours. It is worth noting here that the instrumentalisation of this process would involve choosing a number of nodes rather than edges to update as such there will not be any factors of 2 to differentiate between ego or alter.

$$\begin{aligned} p_{ij}&= \frac{1}{1+\exp {[-\beta (\pi _j - \pi _i)]}} \\ h_i(0,1)&= \frac{1}{\tau _s}\sum _{j\in V} \frac{p_{ij}}{k_i}{\tilde{s}}_j a_{ij} \nonumber \\ h_i(1,0)&= \frac{1}{\tau _s}\sum _{j\in V} \frac{p_{ij}}{k_i}(1-{\tilde{s}}_j) a_{ij} \nonumber \end{aligned}$$
(21)

Note that as payoffs in \(p_{ij}\) can be simplified by Eq. 2, \(\pi _i = -\sum _{l\in V} L'_{il}s_l\), we can rewrite the exponent in terms of only strategies and adjacency \(\pi _j - \pi _i = \sum _{l\in V}(bs_l - c)(a_{jl}-a_{il})\). The evolution of the cooperation probability is thus given below.

$$\begin{aligned} f^s_i&= \frac{1}{\tau _s}\sum _{j\in V}\frac{p_{ij}}{k_i}a_{ij}\big [(1-{\tilde{s}}_i){\tilde{s}}_j - {\tilde{s}}_{i}(1-{\tilde{s}}_{j}) \big ] \nonumber \\&= \frac{1}{\tau _s k_i}\sum _{j\in V}p_{ij}a_{ij}\big [{\tilde{s}}_j - {\tilde{s}}_i \big ] \nonumber \\&= \frac{1}{\tau _s k_i}\sum _{j\in V} \frac{a_{ij}({\tilde{s}}_j - {\tilde{s}}_i)}{1+\exp [-\beta \sum _{l\in V}(bs_l-c)(a_{jl} - a_{il})]} \end{aligned}$$
(22)

Once the network is dynamic, simply replace \(a_{ij}\) with \({\tilde{a}}_{ij}\) for when adjacency is probabilistic.

5 Results

In this section we present several results and discussions - mainly agent-based simulations with some theoretical results to complement - in order to highlight the advantages of the framework. We begin with the graph-theoretic models sans strategy - that is cooperators and defectors are fixed but they may change friendships - to illustrate how the network evolves and the structures that emerge. As both extreme popularity and active linking produce similar core-periphery mesostructures, we then combine extreme popularity - being the simplest model - with the three behavioural models: imitate-payoff, conditional cooperation and pairwise comparison. In doing so we identify cases where timescales separate and cases where they do not.

For our computational examples and illustrations in Figs. 2, 3, 4 and 5 we simulate using \(N=20\) agents, 100 runs of a Prisoner’s Dilemma with \((b,c)=(100,50)\) to be in line with the experiments of [43]. Each simulation is ran for \(5T=950\) time-steps, where T is the number of dyads \(T=N(N-1)/2=190\). In this way, as 1 edge is updated at each time-step, then on average in T time-steps then all node pairs (dyads) are updated once.

Moreover, our simulations begin with a variety of initial network conditions, that is networks produced by different random graph generators.

  • Erdös-Rènyi (ER) - the canonical random graph model where pairs of nodes are connected with probability \(p=0.2\).

  • Barabási-Albert (BA) - a preferential attachment model that grows a network of \(N=20\) nodes by continuously adding nodes with \(m=3\) edges.

    • Random assignment (rBA) - the initial cooperators are randomly assigned.

    • Highest assignment (hBA) - the initial cooperators are assigned to the nodes with highest degree.

  • Cooperator Clique (CClique) - the \(C=15\) initial cooperators are completely connected to one another as a clique, while the remaining defectors are entirely disconnected from all others.

  • Complete - all nodes are attached to one another.

  • Stochastic Block Model (SBM) - specifically we use the assortative planted partition model [6], a special case of an SBM, with 2 communities, with an in-group edge probability of \(p=0.8\) and out-group edge probability of \(q=0.02\).

5.1 Fixed strategy

By fixing strategies we can more clearly understand what graphs form as a consequence of \(f^g\). In particular we see the emergence of mesoscale structures such as core-periphery (specifically the continuous core-periphery model [3]). The strength of such structures depend on how friendly and attractive cooperator/defectors are as friends as well as the perseverance of friendship types, however in most realistic settings (where cooperators are universally popular and defectors are avoided) a cooperator-core forms while a defector-periphery struggles to attach themselves to the core while largely avoiding one another. Henceforth for brevity we denote the mesoscale structure of cooperator-core-defector-periphery as CCDP.

Fig. 2
figure 2

Evolution of payoff per capita as agents play a Prisoner’s Dilemma with fixed strategies and where cooperators have extreme popularity (see Graph-theoretic Model 1). Colours indicate the random graph model used to initialise a game (see Appendix for details); faint lines indicate individual runs while the bold lines represent the CANDY results, Eq. 25; the black dashed line is a baseline if all agents cooperated and were on a complete graph. Time has been rescaled by the number of dyads, \(T=N(N-1)/2=190\), so that every T time-steps on average all pairs have been updated once

5.1.1 Extreme popularity

For the extreme popularity graph-theoretic model, Eq. 18 can be analytically integrated, thus leading to equations for \({\tilde{a}}_{ij}, k_i\) and \({\bar{\pi }}\).

$$\begin{aligned} {\tilde{a}}_{ij}(t)= & {} \bigg (\alpha _{ij} - \frac{s_i+s_j}{2}\bigg )e^{-t/\tau _g} + \frac{s_i+s_j}{2} \end{aligned}$$
(23)
$$\begin{aligned} k_i(t)= & {} \bigg (\kappa _{i} - \frac{Ns_i+C-2s_i}{2}\bigg )e^{-t/\tau _g} + \frac{Ns_i+C-2s_i}{2} \end{aligned}$$
(24)
$$\begin{aligned} {\bar{\pi }}(t)= & {} \big ({\bar{\pi }}(0) - {\bar{\pi }}_* \big )e^{-t/\tau _g} + {\bar{\pi }}_* \end{aligned}$$
(25)
$$\begin{aligned} {\bar{\pi }}_*= & {} \frac{b-c}{2N}(N+C-2)C \nonumber \\ {\bar{\pi }}(t)= & {} \big ({\bar{\pi }}(0) - {\bar{\pi }}_* \big )e^{-t/\tau _g} + {\bar{\pi }}_* \end{aligned}$$
(26)

where \(\alpha _{ij},\kappa _i\) and \({\bar{\pi }}(0)\) are the respective initial conditions.

In order to supplement the theoretical prediction (Eq. 25) we run agent-based simulations following the extreme popularity model. As we see in Fig. 2 regardless of the initial condition - that is the network generation model used to initialise friendships - all converge to the same payoff per capita (Eq. 26). Moreover, only a small subset of possible graphs can generate this value \({\bar{\pi }}_*\); for XY the number of CC and CD edges respectively, \(4X+2Y = (N+C-2)C\).

In fact the graphs that form all exhibit core-periphery structure similar to what is illustrated in Fig. 1, regardless of initial condition and partner-update rule, so long as they follow the assumption that “cooperators are popular” and that there are \(C>0\) cooperators - as we will see in the next subsection. In other words this cooperator-core defector-periphery (CCDP) is a stable configuration, along with any entirely disconnected network of pure defectors.

5.1.2 Active linking

In the notation of the original paper [34] denote the number of CCCD and DD-edges as XY and Z respectively; in terms of elements of the adjacency matrix, the edge-set sizes are simply the double sum over \(i,j>i\) of the elements \(a_{ij}\) multiplied by the relevant indicator function. In other words by taking the sum of each of the three terms in Eq. 19 we recover exactly the evolutionary equations for XY and Z laid out originally [34],

$$\begin{aligned} \frac{dX}{dt}&= \alpha _C^2(X_m - X) - \beta _{CC}X \\ \frac{dY}{dt}&= \alpha _C\alpha _D(Y_m - Y) - \beta _{CD}Y \\ \frac{dZ}{dt}&= \alpha _D^2(Z_m - Z) - \beta _{DD}Z \end{aligned}$$

where \(X_m, Y_m\) and \(Z_m\) are the maximum sizes of the edge sets given a number of cooperators C in the population. The steady state solution is thus given by

$$\begin{aligned} X_*= & {} \frac{\alpha ^2_C X_m}{\alpha ^2_C + \beta _{CC}} \\ Y_*= & {} \frac{\alpha _C\alpha _D Y_m}{\alpha _C\alpha _D + \beta _{CD}} \\ Z_*= & {} \frac{\alpha ^2_D Z_m}{\alpha ^2_D + \beta _{DD}} \end{aligned}$$

In a realistic setting cooperators rarely broke from each other [43] so that \(\beta _{CC}\approx 0\) while defectors are regularly unfriended by everyone [10] \(\beta _{DD}\gg \alpha _D^2\). We see therefore that \(X_*\approx X_m\), \(Z_*\ll Z_m\) and \(Y_*\in [0,Y_m]\). In other words we can see a very clear core-periphery emerging, whereby cooperators form a core and defectors are typically isolated in the periphery. This mesoscale structure has been seen elsewhere in the literature, such as in multidimensional opinion spaces with only edge-breaking [53].

Fig. 3
figure 3

Extreme popularity, imitate-payoff. After agents have played 5T rounds of a Prisoner’s Dilemma, following GM1 and BM1, the final payoff per capita is plotted for different ratios of strategic to graph-theoretic timescales \(\tau _s/\tau _g\). Each point is an ensemble average over 100 simulations, with colour denoting the initial condition; the black dashed line is a baseline if all agents cooperated and were on a complete graph. Note towards the fixed strategy limit the rate of cooperation is bounded-from-above by the initial level of \(C=15\)

Once again we emphasise the emergence of a core-periphery, despite the difference in partner-update rules. In fact once strategies are allowed to change, as we will see in the next section, the two absorbing fixed points of the system are in effect core-peripheries of \(C=0\) and \(C=N\). That is, either the system turns into a complete graph of only cooperators, or an empty graph of only defectors; the stability of these two states is governed entirely by what strategy-update rules are implemented, i.e. the assumptions of how people decide to cooperate or defect.

5.2 Coevolutionary process

Here we address the cases when both edges and strategies can update, and do so on timescales of \(\tau _g\) and \(\tau _s\) respectively. By varying the ratio of timescales, \(\tau _s/\tau _g\), we are able to explore the bifurcations that occur and regard the threshold effect that emerges.

In particular we focus on combinations of extreme popularity (GM1) rule with the three behavioural models to produce very different timescale curves (Figs. 3, 4 and 5), by simulating 100 simulations for each combination at different ratios of strategic to graph-theoretic timescales \(\tau _s/\tau _g\). After 5T rounds the ensemble-average payoff per capita is measured and plotted. A commonality to note is towards the fixed strategy limit, the rate of cooperation tends towards the initial \(C=15\) precisely because exceedingly few people have changed from cooperate to defect (or vice versa).

For comparison, in experiments where a fraction \(\nu \) of subject pairs - such as in [65] and [57] - are picked at random to update every round, \(\tau _s/\tau _g = \nu \). In much of the experimental literature [43, 44, 57], there are 3 typical values for \(\nu \): the fixed (\(\nu =0\%\)), viscous (\(\nu =10\%\)) and fluid (\(\nu =30\%\)) conditions. They all found that the fluid condition has higher levels of cooperation than either the fixed or viscous cases, in other words higher \(\nu \) have higher cooperative levels. We replicate these results with simulations across the different update rules (see Figs. 3 and 4 ) and show how other unseen phenomena may also occur.

Fig. 4
figure 4

Extreme popularity, conditional cooperation. After 5T rounds of a Prisoner’s Dilemma, following GM1 and BM2, the final payoff per capita is plotted for different ratios of strategic to graph-theoretic timescales \(\tau _s/\tau _g\). Each point is an ensemble average over 100 simulations, with colour denoting the initial condition; the black dashed line is a baseline if all agents cooperated and were on a complete graph. Note towards the fixed strategy limit the rate of cooperation is bounded-from-above by the initial level of \(C=15\). Cooperators find it easy to defect in the left panel, requiring only \(20\%\) of neighbours are defectors. In the right panel a switch to defection requires a majority of neighbours to already be defectors

5.2.1 Imitate-payoff

As seen in Fig. 3, there is a separation of time scales in most realistic graphs under extreme popularity (GM1) and imitate-payoff (BM1). After such a long period of time most of the realistic graph models behave near identically with mass defection occurring consistently for \(\tau _s/\tau _g < 10\) and non-zero levels of cooperation persisting above this threshold. The difference in behaviour between the static network limit and the dynamic network - that the fraction of cooperators is higher in the dynamic case - has been observed in experiments [65].

However for the CClique initial graph - a highly artificial/pathological network where all cooperators begin as friends with all defectors entirely disconnected - playing under the same rules a reverse Goldilocks zone appears. That is for intermediate values of \(\tau _s/\tau _g\) defection is rife, while towards the fixed network limit cooperation is nearly maximal.

From an individual’s perspective placed in a realistic graph, defection is the optimal and preferential strategy - the population is mixed enough that defectors can infect cooperators. As such when strategies can update quickly enough, all players have enough time to defect hence mass defection occurs. However when strategies are slow to update, there simply is not enough time for everyone to defect; consider when \(\tau _s/\tau _g = 10\), although all pairs have been updated around 5 times each, only around half of possible imitation updates have occurred.

In contrast, the CClique condition actually promotes cooperation at the individual level, at least in the early stages, precisely due to the core being resilient against defection. Note that the strategy vector \(\varvec{s}\) will only start to change once a defector has attached to the core - otherwise there will be no alternative strategy to imitate from. Provided the core is large enough, when strategies update rapidly the likelihood of a defector imitating a cooperator is far higher than the reverse, in other words the core converts defectors quicker than they can infiltrate the core. As the edges update quicker, more and more defectors can attach themselves to the core quickly enough to start converting the cooperators. After some point strategies become too slow for everyone to defect hence the payoff per capita rises again in the limit of fixed strategy. These two competing factors thus produce a reverse Goldilocks zone, where cooperation is minimised, not maximised, at intermediate ratios.

Finally note that for all realistic initial conditions when the network is static (\(\tau _s/\tau _g=0\)), we reproduce the qualitative result, seen empirically in [16, 17] and theoretically in [59], that static networks do not promote cooperation. In fact this behaviour appears again for different strategy update rules, such as the conditional cooperation in the left of Fig. 4. However let us be clear that this is not always the case, across all static networks and across all update rules; we can qualitatively capture the discrepancies seen in the literature.

5.2.2 Conditional cooperation

As shown by Fig. 4 the choice of behavioural model, which a priori is as reasonable as any other, may produce vastly different results. For \(v = (0.2,0.8)\), that is when cooperators easily defect, we see a similar curve for most realistic initial conditions as in the imitate-payoff case - heavy defection for low ratios with higher cooperation at higher ratios. However we already see differences, for a start when cooperators have the highest degree in a scale-free graph non-zero cooperative levels are maintained at all \(\tau _s/\tau _g\). This directly contrasts the rBA condition, where cooperators are randomly assigned in a scale-free graph. This result alone implies possible policy implications in order to sustain global cooperation.

Second, unlike in Fig. 3, the CClique condition no longer produces a minimum in cooperators, instead there is a clear separation where mass cooperation occurs. If the simulations were to run longer then we would see mass cooperation at all ratios, whereas for the realistic initial graphs mass defection would occur. This suggests that for this parameter set, this rule combined with the network structure heavily promotes cooperation at all times.

Third, we see how the parameter values control the extent to which cooperation is promoted, looking at the right of Fig. 4. This happens because the threshold to defect is now much higher, so that cooperators remain cooperative, while defectors begin to cooperate, thus cooperative rate only ever increases.

5.2.3 Pairwise comparison

For \(\beta =1\) the timescale curve of the pairwise comparison model, Fig. 5, behaves similarly to the conditional cooperation for high defecting threshold. That is cooperation is promoted across all \(\tau _s/\tau _g\) likely as there are already many cooperators to begin with so that a defector feels an immense amount of peer pressure to cooperate. In this case when \(\beta \) is lower, the resultant level of cooperation will be similarly smaller, as there is less pressure to imitate them; otherwise increasing \(\beta \) would increase the speed at which mass cooperation happens. Moreover, we suspect the role of initial number of cooperators to be vital, that varying \(C_0 \equiv C(0)\) will lead to a bifurcation in \(C_\infty \equiv C(t\rightarrow \infty )\). Already two bifurcation points are trivial, \(C_0 = 0\) and \(C_0 = N\), as in both cases there are no alternative views to copy hence \(C_\infty = C_0\).

Interestingly here, the CClique initial condition produces the lowest payoff per capita - unlike under different behavioural models. Even nearer the fixed strategy limit, the payoff per capita is around 50 units short of the realistic networks - this suggests that inside the core roughly one cooperator has had the chance and decided to defect.

Consider the CClique’s evolution at intermediate times - that is when defectors have connected to the core but no agent has changed strategies - where there are \(C_0\) cooperators and each cooperator has on average d defecting friends (hence each defector has on average \(C_0 d/D\) cooperative partners. For a cooperator i and a defector j, the expected payoffs are \(\pi _i = 50(C_0 - 1 -d)\) and \(\pi _j = 100C_0d/(N-C_0)\), such that the probability for i to imitate j following Eq. 21 and given the conditions of our experiment, is as below.

$$\begin{aligned} p_{ij} = \frac{1}{1+\exp {[-200(d-2)]}} \end{aligned}$$

Here we see immediately that it becomes increasingly likely a cooperator i will defect, once \(d\ge 2\) defectors have connected to her. Moreover, when \(\tau _s/\tau _g>> 1\), we can use Eq. 23 to estimate \(d(t) \approx (1-\exp (-t/\tau _g))D/2\) - so that d grows rapidly past \(d=2\) towards \(d=D/2\). In other words cooperators will be under immense pressure to defect. However as \(\tau _s\) is large, only very few agents have the opportunity to update their strategies, hence we typically only see 1 cooperator defect.

Fig. 5
figure 5

Extreme popularity, pairwise comparison. After agents have played 5T rounds of a Prisoner’s Dilemma, following GM1 and BM3, the final payoff per capita is plotted for different ratios of strategic to graph-theoretic timescales \(\tau _s/\tau _g\). Each point is an ensemble average over 100 simulations, with colour denoting the initial condition; the black dashed line is a baseline if all agents cooperated and were on a complete graph. Note towards the fixed strategy limit the rate of cooperation is bounded-from-above by the initial level of \(C=15\) and note also that the upper y-axis limit is significantly higher than all previous figures

6 Discussion

By exploring different, but equally plausible, update rules - a proxy for hypotheses about agents’ behaviour - we have observed the emergence of qualitatively contrasting phenomena surrounding cooperation, that have each been reported by various theoretical and experimental works. In using a singular framework, CANDY, we are able to isolate which assumptions and to what end they promote mass cooperation, suggesting that discrepancies in the literature arise from different assumptions and experimental design than being necessarily descriptive of real-world behaviour.

Through our framework we have been able to reconstruct the qualitative results of many previous works, even where they may at first glance seem contradictory. For a start, multiple experiments [43, 44], agent-based simulations [48] and theory [12, 33, 39] show that non-zero levels of cooperation are maintained when strategies are updated sufficiently quick (\(\tau _s/\tau _g\) small) or similarly when networks are fully static; we see this across all initial networks for the pairwise comparison rule (Fig. 5) and for the conditional cooperation under the right parameter regime (right of Fig. 4). Moreover, for some rules we considered, we see a threshold effect in the timescales that has been theorised by [34] and [49] while in other cases we see a distinct lack of one as in the conditional cooperation (right of Fig. 4) reported by [65]. Finally we are able to replicate some of the empirical trends seen in experiments [43, 65], that for higher \(\tau _s/\tau _g\) a higher rate of cooperation is maintained.

Our analysis suggests that although the speed of interactions (both behavioural and relational) is an important factor, it is not in general a sufficient condition for mass cooperation as suggested in [26], and is largely a by-product of the finite nature of the game. In the majority of conditions, we observed a threshold effect in the relative update speed \(\tau _s/\tau _g\); however given infinite time for any ratio of timescales, such a ’threshold’ disappears, and mass cooperation/defection depends upon the condition. For example as seen in the conditional cooperation with extreme popularity, the initial network structure matters immensely and can either promote cooperation or promote defection. In other words, time-permitting, what truly matters is the context, the game structure(s) and the decision-making style of agents, not the relative speed of updates.

The one exception is in the single case of a so-called Goldilocks zone in defectors, where, for the pathological CClique initial network, a near static network promotes cooperation while rapid edge updates seem to favour defection. In the infinite time limit we would expect to see a threshold emerging.

Notable future research avenues include the study of games other than the Prisoner’s Dilemma and the analysis of real-world group formation, such as working groups exhibiting hierarchical compartmentalisation and shifting pairwise interaction (e.g., Facebook or MS Teams).

Understanding the core-peripheral structures that emerge in real-world interaction, where cooperators collaborate closely with one another and defectors are ostracised, may have useful policy implications.

A further avenue for future work would be to explore a protocol whereby defectors are slowly engaged and introduced into the cooperator-core, to reduce the temptation on a cooperator to defect and to ease the defector into a more positive mindset.