From self-interest to cooperation: extra-pair mating as a driver of relaxed territorial aggression in social neighbourhoods

In socially monogamous bird species, males and females tailor their reproductive strategies to that of the other. Interactions are complex, and have elements of both conflict and cooperation. Breeding process is further complicated with the occurrence of matings outside the pair bond, which is a frequent phenomenon in these species. Extra-pair mating has clear benefits for males, but cuckolded males may withdraw care and resources at a cost to females, which produces an unbalanced costs-to-benefits ratios within the mating pair. We used an individual-based model with social networks approach, to study how female extra-pair mating strategies may affect male investment in offspring care and territorial defence. In our model, extra-pair copulation rate is a female-driven strategy; we use two adjustable male traits—care and territorial defence—that co-evolve with that strategy and control the number of extra-pair copulations initiated by a social female. The model utilises very simple rules of behaviours between individuals that lead to the emergence of evolved changes in mating strategies on a large scale. We show how extra-pair copulations initiated by females in their neighbourhood can reduce territorial defence and wasteful aggression between the males across the whole population. We propose that female mating behaviour and male responses are flexible traits that might serve as potential drivers of the evolution of cooperation.


Introduction
Observing a pair of birds preparing a nest, brooding the eggs, and feeding the chicks until they fledge comes across as a joint and synchronised effort, but also as arduous and allconsuming. Great was the surprise when DNA fingerprinting revealed how in most small birds the male feeds and defends a brood where typically 10-20% of the chicks are not sired by him (Brouwer and Griffith 2019). The behaviours that lead to extra-pair paternity (EPP)-courtship and copulations outside the pair bond-are generally hard to notice for human observers, and for long remained anecdotal (Westneat 1987). Field scientists were largely unaware of this phenomenon until the first reports about genetic paternity in wild birds started to appear in the 1980s (Wetton et al. 1987;Gowaty and Karlin 1984;Birkhead et al. 1990;Lifjeld et al. 1993). Since then, DNA techniques have documented extra-pair paternity in the majority of studied species. At the population level, EPP ranges from a few percent of extra-pair offspring in, e.g., the long-lived black-browed albatross (Thalassarche melanophris, Burg and Croxall (2006)) to more than 50% e.g., in the tree swallow Tachycineta bicolor (Kempenaers et al. 1999).
Males can easily obtain clear fitness benefits from additional paternities and are therefore expected to actively pursue extra-pair copulations (EPC). In some species such as the zebra finch (Taeniopygia guttata), it is suggested that males control extra-pair mating (Forstmeier et al. 2011) and that female extra-pair mating is maladaptive but exists because of genetic correlations and strong selection on the male version of the trait (Forstmeier et al. 2014). Benefits to females could be related to good genes for their offspring if mated extrapair with particular males (Trivers 1972). Females could also avoid brood failure due to an infertile mate by engaging in extra-pair mating (Hasson and Stone 2009). Beyond that it is the potential costs to females that dominate the literature, in particular the risk that social males reduce on care contributions to offspring (Arnqvist and Kirkpatrick 2005;Birkhead and Møller 1993;Dixon et al. 1994).
Several circumstances complicate the process of explaining and understanding extrapair mating. The anatomy of reproductive organs gives most female birds control over who they mate with and when (Birkhead and Møller 1993;Gray 1996). Evidence from movement loggers corroborates that females actively solicit extra-pair copulations in e.g., superb fairy-wrens [Malurus cyaneus; Double and Cockburn (2000)], or males take initiative and females accept or reject as in song sparrows [Melospiza melodia; Akçay et al. (2012)]. If extra-pair mating played a negligible adaptive role for females, one would expect that it varies with phylogenetic relatedness due to neutral evolution and drift, but there is large and systemic variation between species and populations based on their ecological context. Gray (1996) found that in red winged blackbirds (Agelaius phoeniceus), EPP was 45% when birds nested in broad pocket marshes, and only 26% when they nested in the linear strip marshes. Similar contrasts have been found in superb fairy wrens, nesting in honeycomb-like structured territories in open habitats (59%) versus along the stream (41%) (Bain et al. 2014). In the purple-crowned fairy wren (Malurus coronatus), which is a closely related species, EPP rates are as low as 4% (Kingma et al. 2009), indicating that ecological factors rather than phylogeny determine propensity to mate extra-pair. Differences have also been found between island and mainland populations of house sparrows [Passer domesticus; Griffith et al. (1999)].
There are also studies that suggest links between extra-pair mating and predation or longevity. Scaring a breeding blue tit (Cyanistes caeruleus) female with a fake predator elevated extra-pair mating compared to females who were just disturbed (Santema et al. 1 3 2020). Higher tendency for extra-pair copulations was also reported in blue tit females that had experienced brood failure during previous breeding seasons (Mennerat et al. 2018). Male pied flycatchers (Ficedula hypoleuca) were more willing to support their neighbours in predator mobbing if they had extra-pair offspring in the nest under attack (Krams et al. 2022). Across species, a negative correlation between longevity and extra-pair mating has been found in some comparative studies (Arnold and Owens 1998) but not in others (Brouwer and Griffith 2019).
For males, lost paternities imply reduced fitness, so males of many species have evolved counter-strategies to maintain a high rate of within-pair fertilisation, including mate guarding and frequent copulations (Petrie and Kempenaers 1998). Mate guarding is particularly costly and interferes with feeding and rest and may leave males completely exhausted towards the end of the egg-laying period. Despite impressive male efforts, extra-pair paternities are still common, suggesting extra-pair mating somehow must be advantageous to females.
Taken together, the patterns above suggest that extra-pair mating is an adaptive trait that is flexibly tailored to local conditions, possibly driven by females (Gray 1996). The evidence for indirect genetic benefits to females is numerically weak (Brouwer and Griffith 2019), implying that a dominant driver rooted in local ecological interactions likely is missing. What drives the evolution of mating outside the social pair-bond remains an important and unanswered question that we will address here.

Introduction to the model
Our starting point is a theoretical model that describes how extra-pair copulations alter male incentives for investing in the home nest relative to the local neighbourhood, first proposed by Eliassen and Jørgensen (2014). When a male sires offspring in neighbouring nests, his extra-pair young benefit if the male shares resources or otherwise engages in cooperative behaviours. The model investigated two such cooperative behaviours: antipredator strategies such as vigilance networks or predator mobbing that increase the survival of both within-pair and extra-pair offspring; and reduced territoriality that would make it easier for the neighbouring female to find food, which benefits a male's extra-pair offspring while he simultaneously can free time from territorial defence and thus provide more care in his home nest. Extra-pair copulation could therefore have a systemic effect whereby females indirectly could incentivise males to spend less time and resources on wasteful competition but rather work together to produce a safer and more productive neighbourhood. This has been dubbed the "nicer neighbourhoods" hypothesis.
A key prediction from the nicer neighbourhoods model (Eliassen and Jørgensen 2014) is that females may obtain whole-nest benefits from extra-pair mating, as seen in e.g., blue tits, where production and survival of fledglings is positively correlated with number of extra-pair sires (García-Navas et al. 2014). A second prediction is that territoriality will be relaxed after eggs have been fertilised, which aligns with a broad review of the "dear enemy" effect in rodents where reduced territorial aggression was observed in species that sourced food from their breeding territory (Temeles 1994), but not if the territory was used for breeding only. A dear enemy effect during the period with dependent young has also been documented in e.g., skylarks (Alauda arvensis; Briefer et al. (2008)).
A main conclusion from Eliassen and Jørgensen (2014) was that female EPC behaviour has the potential to incentivise males to invest differently in territorial defence and care. Monopolising resources likely maximises fitness for a male who has all his offspring in the social nest, but as soon as there is a probability of having extra-pair paternities, strong territoriality will only take resources away from genetic offspring in neighbouring nests. The nicer neighbourhood hypothesis has therefore remained difficult to test empirically, as it relies on numerous small contributions from many individuals, thus being hard to observe and nearly impossible to quantify. Further, EPC is quick and hard to observe, so most empirical studies quantify this behaviour through DNA analysis. Because fertilisation is stochastic if sperm from more than one male is present ) and often biased through post-copulatory sexual selection (Birkhead and Møller 1993), the view obtained by attributing paternities is likely incomplete and its role for studying EPC and its drivers limited.
The methodology of the Eliassen and Jørgensen (2014) model has further important shortcomings that we overcome in this analysis. The algorithm used then assumed populations where all individuals were identical, which hardly aligns with the overwhelming inter-individual variation in behavioural traits observed in wild birds. That individuals were identical also conflated social interactions, which when individuals differ need to be tailored to the local social context through phenotypic plasticity. Finally, the model had to assume that males would respond adaptively to changes in female mating behaviour but did not go all the way to demonstrate that a selection pressure on female extra-pair mating behaviour could emerge and be of sufficient magnitude to cause evolution of the trait in variable populations. In the following paragraphs we explain these shortcomings and how we have overcome them more in depth.
First, we developed an evolving individual-based model that allows for genetic variation among individuals in a population. Model individuals have genes for behaviours, inherited as quantitative traits where mutations cause new variation (Dunlop et al. 2009). This leads to a balance between mutations and selection that causes the emergence of within-population genetic variation. Second, we have formulated the model genes so that they code for simple reaction norms (Stearns and Koella 1986) to incorporate phenotypic plasticity. The male's behaviour is determined by genes that prescribe responses to his social and extrapair females' mating behaviours. We can therefore move beyond the assumption that males can find best responses to local interactions, now males need only keep track of their own matings during a particular season and follow a behavioural response as coded by their genes. The model thus assumes males have limited cognitive abilities, within the range of what can be expected from a wild species.
Finally, the social life of songbirds is complex, and mechanisms underlying complex behaviours-such as the emergence of extra-pair paternity-involve interactions among many individuals. Not only may each individual follow a strategy that is influenced by the social and ecological context, but there are likely strategy differences among conspecifics (Wang et al. 2020) that can coexist in frequency-dependent evolutionary games. Most probably, both genetic and social factors are needed for explaining variation in female mating strategy (Maldonado-Chaparro et al. 2018).
As social structure may have profound impact on the evolution of extra-pair mating, we embedded individuals in a social network, so that each breeding pair has the opportunity to exchange behaviours and adjust their responses accordingly to phenotypes expressed in the closest neighbourhood. One can thus say that an aim of the current model is to include considerable noise as inspired by wild populations, thus building a virtual laboratory that we can manipulate and investigate with a level of detail beyond what is logistically possible in real populations.

Methods
We use a genetic algorithm to describe the breeding processes and inheritance. The focus is on reproductive investment of males and females in offspring care, and defence of breeding territories by males. We consider two cases-for species with short (mainly one breeding season) or long (multiple years) expected lifetimes. The core principles and ideas of the model are described in this section. First, we focus on the important social processes, and mathematical formulas that are used to represent relevant biological interactions, tradeoffs, and dynamics. Then, we introduce technical assumptions and model implementation.

Social interactions
While we cannot implement all the social complexity in the model, we incorporated a social network through nests being placed as nodes on a grid. Neighbours share borders over which territorial behaviours determine access to resources and across which extra-pair mating can take place. Individuals behave according to genetically coded behaviours that evolve through variable social interactions.
In our model each node represents a territory with a nest occupied by a breeding pair, with connections that indicate the possible behavioural interactions. Note that in real systems social proximity does not always align with spatial arrangement of nests (Westneat and Mays 2005), however, it is a valid assumption in other cases (Mayer and Pasinelli 2013;Cousseau et al. 2020).
The main idea of the model is illustrated in Fig. 1. Both parents provide care, which involves finding and bringing food to the offspring as well as providing safety at the nest. In addition, males invest in territorial defence, which secures resources in competition with neighbouring males. All these actions are summarised in one equation, describing the likelihood of producing viable offspring by a social female (Eq. 1): W f is referred to as expected reproductive success (fitness function), R is the amount of available resources resulting from the male's territorial behaviour, the parenthesis is the effect of care from both parents ( C m and C f for male and female care, respectively), while S m and S f are the probabilities that the parents survive to provide that care. alpha and gamma coefficients were used to model diminishing returns functions. The contribution of resources and care are multiplied because there is no point in securing resources if the food is not gathered and provisioned, nor is there any point in spending time searching for food if there is no access to resources to begin with.

Females
Female extra-pair mating behaviour is defined in the model as a genetic trait (denoted as x) that represents her probability of engaging in copulations outside the social pair-bond. A female with high genetic EPC value will solicit many extra-pair copulations with all the males in her closest neighbourhood, lowering the chances of the social male for siring the young. For example, a female with an extra-pair copulation rate of x = 0.30 will engage in 1 3 copulations with her social partner 70% the time, while the rest is spent on extra-pair copulations, distributed evenly between neighbouring males.
For each offspring, the genetic sire is drawn randomly, proportionally to each male's copulation rate with the female. Therefore, EPC behaviour translates to extra-pair paternity, but because of stochastic processes, it is not a direct measure of extra-pair young present in the home nest nor of realised paternities across nests. EPC in the model is an evolving trait and its expression is not associated with any direct social cost (e.g., harassment or forced copulations initiated by the social partner, Birkhead and Møller (1993)) or elevated risk of mortality or disease. Male responses to extra-pair mating may, however, alter the social male's care investments, potentially inflicting costs on females. Females are also characterised by two direct, fixed (e.g. the same for each female and constant in time) costs: egg production (denoted in the equations as E) and care for the offspring ( C f ).

Fig. 1
Strategies and behaviours that influence reproductive success. The basic operational unit in our simulation is a territory, defined as an area occupied by one social pair. Each territory includes a nest and food resources for feeding the offspring. Main interactions between individuals in our model consist of four behaviours: territorial defence (red arrows), extra-pair copulations (EPC, blue or yellow arrows), withinpair copulations (WPC, blue or yellow arrows) and care for offspring (green arrows). EPC and territorial defence are performed between individuals occupying adjacent nests (first-degree neighbours). In the upper part of the diagram there is a simplified social network that consists of five territories (graphically represented as nodes) with two highlighted nodes and one connection between them. The directions of behaviours that are expressed between individuals occupying those adjacent nests are indicated by arrows. Fitness function for each female is calculated based on the amount of resources (R 1 , R 2 ) available at the nest and combined care efforts of social male and female. In the picture bright coloured birds with red chests symbolise males, females have dull plumage. The colour of each egg corresponds to the EPC/WPC arrows and indicates if the offspring is extra-or within-pair Males EPC expressed by a female has a negative effect on the fitness of her social male (paternity loss) but positive effect on the neighbour (extra-pair offspring), hence it may affect investments of all her mates (Perlut et al. 2012). Male behaviours during the breeding season are adjusted to partners' actions via reaction norms (Nussey et al. 2007). They are mathematically represented in our model as a linear function (when male behaviour depends on one variable) or a two-dimensional plane (two separate variables). We focus on two male strategies: territorial defence and care for offspring in the nest. The strategies are not mutually exclusive (i.e., a male can invest in both care and defence) but higher investment in total is related to higher mortality risk. Male investment in care ( C m ) depends on two evolving genetic coefficients ( c 1 , c 2 ) and uses the information about the EPC of his social female (x): In a given mating situation, this allows the male to adjust the amount of care he provides, based on his assessment of paternity in the social nest.
Males also defend resources and breeding territories. We refer to defence effort directed at one particular neighbour as partial territorial defence. Let us consider a simplified case with two males, one occupying nest i, and the other nest j. Partial territorial defence is regulated by three genes ( d 1 , d 2 , d 3 ); the investment of the i-th male can be summarised as described by Eq. 3: where ( 1 − x i ) is the within-pair copulation rate with the focal female and x j represents extra-pair copulation rate of the female in nest j; both terms thus represent potential paternities. d 1,i , d 2,i and d 3,i components define the reaction norm of the i-th male. Male j would make a similar decision based on his strategy and EPCs of the females he engages with in the neighbourhood.
A population consists of many nests and borders, the total expressed defence of the ith male is the average of all actions towards his neighbours. The mechanism of territorial defence between two males is illustrated schematically in Fig. 2. i,j translates to the size of a territory gained near one specific border (in this case denoted by i,j ). The total number of resources that a male can secure for his social female and the offspring in the home nest is a sum of all partial territories ( i,j + i,k + … = R i ). The model assumes that males have full information about their own copulations but they cannot directly know the behaviour of their male neighbours. All reaction norm coefficients are evolving independently, thus all combinations of phenotypes are theoretically possible.

Survival and breeding
Both males and females are subject to a trade-off where the sum of costs from actions performed during the breeding season (i.e., total reproductive investment) reduces their survival rate. The costs can be associated with predation risk, injuries, or energy loss. We distinguish between two types of survival probabilities: related to within-season survival (denoted by S m for males and S f for females) and between-seasons survival (P m , P f ). Individuals with lower total reproductive investment have higher chances of surviving to the next breeding season. An individual's probability of surviving depends on environmental factors represented by a baseline mortality rate (m 0 ), and additional mortality risk that increases with total reproductive investment (m R ). Details and equations of the functions, as well as other principles of the model, are provided in Table 1.
Detailed sensitivity analyses were performed for the previous version of the model (Eliassen and Jørgensen 2014) to investigate how trade-offs and curvature of relationships would influence EPC. Baseline values for all parameters presented in Table 1 are based on that model.
For simplicity, we maintain a constant population size throughout the years, consisting of equal number of nests and networks. Individuals that survive to the next breeding season are recruited into breeding sites and paired with a random partner. They usually account for 10-30% of the population (depending on their survival strategy), and the rest of the population consists of first-season breeders. Females are sorted based on their fitness Fig. 2 A schematic representation of actions that determine the size of territories during each breeding round. Let us assume a simple case with two males who defend territories. Initially all territories in the model are equal in terms of size and food abundance, but males can shift borders by adjusting territorial defences. Males are actively aggressive towards their neighbours (represented by blue and yellow arrows), which guarantees best access to resources for their offspring-both within-pair and extra-pair young. In the above situation, a male in the nest on the right side is acting with lesser force than the male to the left ( 1,2 > 2,1 ). He therefore loses some resources at his home nest but gains more resources for his extrapair young in the other nest. As a result, the territory of a male to the left becomes bigger than the territory secured by the opponent. Males adjust their investment in territorial defence according to their social female fidelity (or the number of within-pair copulations, WPC) and the EPC of a female in the neighbourhood. We do not restrict the coefficients of the partial defence function so the reaction norm plane can have any orientation in the variable space. In the model, where population consists of many nests and borders, a male's total expressed defence (D) is defined as a mean of all actions towards his neighbours Table 1 Functions, variables and parameters used in the model Female between seasons survival (p) Male between seasons survival (p) score (Eq. 1), which determines their chances of producing viable offspring. The male sire is selected among closest neighbours, according to the female's EPC strategy (Fig. 3, left side). In offspring, the expressed value of each trait is drawn form a Gaussian distribution with mid-parental value as a mean, and a fixed variance of 0.05. It represents the noise due to segregation, recombination, and mutations (Fig. 3, right side). We use a genetic algorithm (Holland 1992) across thousands of generations to evolve adaptive solutions. The algorithm is repeated for a set number of years.
Each breeding season, males and females are assigned randomly to nests; the model does not consider mate choice although older individuals are given priority when establishing breeding territories and attracting mates compared to new recruits. There are no particular selection rules in terms of choosing breeding site, as partners and neighbours are assigned randomly each year. Position in the network, mate, and therefore social context are consequently changing between consecutive breeding seasons. Fig. 3 Breeding and inheritance. Left: for each breeding season, we simulated a population of several thousand individuals that occupied social networks (called "neighbourhoods"), each with equal number of nests and connections between them. During each breeding season, individuals interact with their first-degree neighbours through the connections between nodes. Female reproductive success (Eq. 1) determined the probability of having a surviving offspring (indicated as yellow node). The genetic sire was selected among all males in the female's closest neighbourhood-social male (represented by the same yellow node) and her first-degree neighbours (blue nodes)-depending on the relative number of copulations (EPC and WPC) that a female had with each male. Right: genetic values are determined by parent genotypes. For each gene, the offspring inherits a value drawn from a normal distribution, with mean equal to the mid-parental value of the trait. In females only EPC is expressed, males express c 1 , c 2 , d 1 , d 2 and d 3 genes

Simulations
A single simulation consisted of 220 identically structured social networks referred to as neighbourhoods. Each neighbourhood was constructed as a ladder network of 24 nests, where every nest had exactly three neighbours (connections) with no rewiring probability (Fig. 3). This resulted in a population size of 10,560 breeding individuals across 5280 nests, which was large enough to observe evolutionary change without succumbing to stochastic noise. The type of network and population size were selected empirically, to maximise code efficiency.
The first generation of individuals in each simulation was initialised as described in Table 1. Simulations were started with four different EPC values (0.0, 0.2, 0.4, 0.6), two levels of mortality to illustrate different longevity scenarios, and in three replicates, that resulted in 24 runs. We additionally performed one run with non-evolving female extrapair strategy fixed at 0. The expected lifetime of an individual in the short-lived scenario was one year, and in the long-lived between two and three years, depending on the strategy. We performed calculations for 100,000 years for the short-lived, and 160,000 years for the long-lived variant since the latter took longer for evolved trait values to stabilise.
To build an artificial population that emulates the social complexity of a real system with its natural properties, we utilised the concept of object-oriented programming in Python. We used random module for pseudo-random numbers generation and networkx library for generating the social networks, as well as other standard Python libraries for basic mathematical calculations. The algorithm can be found in an online appendix and project code is available in the repository https:// github. com/ arumi nska/ EPP.

Results
Regardless of the initial conditions tested, considerable rates of extra-pair mating evolved as the adaptive female strategy, while males in parallel evolved behaviours of more sharing and caring.

Repeated evolution of extra-pair mating produces similar results
In replicate after replicate, female EPC evolved to high and relatively stable levels, with specific adaptive responses also in the male behaviours of territorial defence and care for offspring. Figure 4 shows the evolutionary changes of genetic traits and expressed behaviours in both sexes. In a population with high mortality rate, so that the expected lifetime was one breeding season, female extra-pair copulation rate repeatedly approached a fluctuating equilibrium of 0.67, implying that two out of three offspring on average were sired by an extra-pair partner. The males' reproductive investment-territorial defence and care provided at the nest-also converged and remained stable at levels of 0.4 and 1.3, respectively. All averages have been calculated based on values from the last 10,000 years. Throughout twelve simulations, in three replicates for four different starting values of EPC, female and male strategies consistently converged to the same numerical values, albeit with some variability between simulations due to stochasticity. The fact that EPC evolved in all replicates where it started from zero is particularly noteworthy.
In all cases, female EPC stabilised after a few thousand years of simulation while male strategies took longer to attain their equilibrium. This is not surprising given that female extra-pair mating behaviour is coded by one numerical gene and is expressed directly, whereas male behaviours are coded with reaction norms of two or three genes that use local information about mating rates to fine-tune behavioural investments.
Initially, males did not adjust their investment in territorial defence, nor care, to female EPC behaviour (Fig. 4d, e both show near-zero slopes for male reaction norms). During this early phase of evolution, there was rapid change of the baseline level of territorial defence and care (male genetic values d 3 and c 2 , Fig. 4f, g), but it took several thousand years of simulation before males used social information to fine-tune their behaviours (Fig. 4d, e). Such use of local information evolved fastest for territorial defence, although that was a more complex reaction with two slopes (d 1 and d 2 components) that translate experienced copulation rates into territorial behaviour. The variety of female phenotypes in the neighbourhood translates into different male-neighbours defence strategies and therefore affects the rate of convergence of the trait. Divergence of the two components indicates that more within-pair copulations translated to higher male investment in territorial defence, whereas more extra-pair copulations with the neighbouring female decreased territorial investment.
In comparison, the slope that indicates how males translate experienced within-pair copulation rates into the expressed level of care changed more slowly and did in some simulations not deviate from zero (Fig. 4e). In most simulations, though, a slightly positive Fig. 4 The evolution of phenotypes and genotypes in a population of short-lived species over 100,000 years. We focused on investigating female and male strategies (graphs a-c), as well as individual genes (graphs d-g). Each line in the graph symbolises one simulation run. A single run is highlighted in each graph to help visualise the trajectory. We initialised the simulations with different starting values of EPC (0, 0.2, 0.4, 0.6) in order to check if the strategies change and converge over time. We repeated simulations three times for each variant of EPC. The lines show population mean values of each trait/gene. See text for detailed description of variables and genetic components response to copulations with the focal female implies that higher levels of EPC had a tendency to trigger more male care in the social nest.

Without EPC, males are more territorial and care less
We also considered the case where female extra-pair copulation rate was fixed at zero (thus allowing no evolution of that trait). Male traits could freely evolve in the situation where all offspring in the focal nest belonged to them. Comparing those simulations to regular simulations with all traits evolving (Fig. 5) illustrates how extra-pair copulations lead to evolution of male strategies with roughly half the level of territorial defence and about 25% more care. From this, one can conclude that female extra-pair mating causes the evolution of less wasteful aggression; because all males behave less territorially it does not redistribute resources but quarrelling that otherwise would require time and energy is avoided which frees time for providing care.

Adaptive levels of EPC vary with longevity
While the results above are reported for a model parameterised with relatively high predation rates and an expected lifetime of circa one breeding season, we also ran the model with a lower predation level which allowed for survival up to three breeding seasons or more. The female EPC strategy converged also for the longer-lived model setup, but to lower values of 0.47, compared to 0.67 in the short-lived model runs. The differences in evolved EPC levels are shown in Fig. 6. In the long-lived case, EPC was characterised by much more dynamics and variability, and it took longer to stabilise even when measured in numbers of generations. Understanding how genetic traits of males and females co-evolve in the long-lived scenario requires more detailed analysis and is not covered by the scope of this work.

Fig. 5
Evolutionary trajectories of three main strategies-EPC, territorial defence and male care with (coloured lines) and without (grey lines) evolving EPC, shown for a short-lived simulation. When extra-pair copulation is free to evolve (a), males evolve territorial defence ca. 50% lower (b), and care ca. 25% more at their social nest (c)

Discussion
A recent review found that 81% of socially monogamous bird species engage in extra-pair copulations, and in some species as much as half the offspring are sired by a male outside the social bond (Brouwer and Griffith 2019). In such situations, males may on average have more offspring dispersed in the neighbourhood than in their home nest. Why do these males remain in social relationships and help raising genetically unrelated offspring, apparently providing nothing but genes to their extra-pair young? And what drives females to actively seek extra-pair copulations?
The "nicer neighbourhoods" hypothesis (Eliassen and Jørgensen 2014) suggested that female extra-pair mating incentivises males to invest less in territoriality and more in care. In this study, we have tested it by developing and analysing an individual-based model of key reproductive behaviours among females and males in local breeding clusters. We found that female extra-pair copulation repeatedly evolved to a substantial and non-zero level, and that compared to the situation with no extra-pair mating males evolved relaxed territorial aggression and increased care at the nest. This combination of extra-pair mating and male cooperative behaviours evolved simulation after simulation, regardless of starting value for EPC, and despite abundant noise at many processes in the model that would normally water down weak selection gradients.
The relationship between extra-pair mating and cooperative behaviours is extremely difficult to document in the wild or recreate in the lab. It involves multiple males and females around each nest, the social context shifts from nest to nest across the breeding cluster, many small behaviours over long stretches of time accumulate to influence hatchling success, and there is great stochasticity that can muddle patterns in studies with limited sample size. This is, therefore, a typical setting where a model, with potential for large populations, long run times, and multiple replicates, can help us infer how weak processes consistently but slowly may cause the emergence of complex patterns that are detectable in data. In other words, when causation is multifaceted and convoluted it can be near impossible to quantify in the wild. Making tractable assumptions in a model is a necessary first step towards concluding that the assumed processes have the potential to cause the observed phenomenon.  Trivers (1974) pointed out how a breeding pair shares genetic interests in their offspring, but also how potential conflicts abound as one parent benefits if the other does more of the work. It follows from Trivers' reasoning how females may increase offspring fitness by additional copulations with high-quality males, while a genetically inferior male can be relied on as social partner. This "good genes" hypothesis describes a clear sexual conflict where females are thought to have evolved extra-pair mating to obtain superior genes, while counter measures, such as mate guarding (Petrie and Kempenaers 1998), withholding care, or deserting the nest have evolved among males to prevent females from promiscuity (McNamara et al. 2000). This female-male dynamic has remained a main explanation for extra-pair mating in socially monogamous species for decades. Several studies have attempted to quantify it and found weak or no effects of the good genes on female or offspring fitness (Sardell et al. 2012;Kempenaers et al. 1999;Kleven and Lifjeld 2005;Lichtenauer et al. 2019).

Extra-pair mating provides ecological benefits to females
Here we extend the perspective of within-pair conflict over fertilisation and workload more in line with Trivers' original analysis, by putting more emphasis on the potential role of cooperation. Since extra-pair mating makes the location of potential offspring more uncertain, it incentivises males to shift the focus from their social nest towards investments that are good for the neighbourhood (Eliassen and Jørgensen 2014). In this model one mechanism is territorial monopolisation of resources. Territorial aggression is time consuming and costly, and if all males decrease aggression there is hardly any redistribution of resources, but it frees time and energy for care at the nest. Reduced aggression is thus a form of cooperation that increases neighbourhood productivity, or, from a different perspective, an important step towards sociality through reduced levels of agonistic behaviours.
The logic of the nicer neighbourhoods hypothesis is similar to that of the infanticide hypothesis, which describes how males sometimes kill dependent offspring to shift females from caring to being receptive to mating and fertilization (Hrdy 1979). The infanticide hypothesis explains that by mating with multiple males, females increase paternity uncertainty, which in turn prevents the male from killing her offspring as they possibly could be sired by him. In both hypotheses, extra-pair mating causes paternity uncertainty and reduced aggression, but they differ as the nicer neighbourhoods hypothesis results in the production of a positive common good (peaceful interactions that allow extra time for care) compared to avoiding costly losses to reproductive investments already made (dead offspring) as in the infanticide hypothesis.

Stronger inference than previous models
The model here studies the same phenomenon and builds on the theoretical approach of Eliassen and Jørgensen (2014) but has several methodological improvements. The 2014 model was based on adaptive dynamics (Dieckmann and Law 1996) and evolutionary invasion analysis (Ferriere and Legendre 2013). Adaptive dynamics assumes a monomorphic population where all individuals use an identical strategy (although it can be stochastic or noisy) and checks whether mutants that are nearby in strategy space can invade. If so, the mutant replaces the resident strategy, and the process is repeated with a new nearby mutant. The method is strong for frequency-dependent problems but does not embrace the abundant inter-individual variation and rich local interactions among individuals common 1 3 to real populations. The current model overcomes this by simulating evolution with a genetic algorithm, where individuals have genetic traits that determine their behaviours.
The keen reader has probably noted that only when males can modify their behaviours in real time to the specific female they engage with do males possess a behavioural feedback that can lead to selection on female extra-pair mating behaviour. This represents a chicken-and-egg question: how can EPC change so quickly and consistently in every simulation, when male reaction norms have not yet evolved? From the start, there is variation in female EPC around the initial values, but it has no consequence for their fitness because male reaction norms are random. Rather, it is the actions of males that through initial variation in territoriality and care cause differences in fitness among nests. The initial trait evolution is thus driven by strong competition between males, causing selection for strategies that increase their fitness, with no directional influence from EPC.
Simultaneously, in the background, a critical genetic reorganisation takes place. Females will be most successful if her social mate is highly territorial while her neighbours have low territoriality (care is always beneficial so we ignore it for now). Now, if she has low EPC, her low EPC genes will predominantly combine with those of her highly territorial social mate. If she has higher EPC, her higher EPC genes will more often be inherited together with low territoriality genes from her extra-pair neighbours. Consequently, male traits are inherited through female success, and low EPC/high territoriality and high EPC/low territoriality tend to become coupled. A similar reorganisation takes place among males. If a male happens to have most offspring in his home nest, high territoriality is beneficial, and this likely occurs when his social female has low EPC. If he happens to have more offspring in the neighbouring nest, low territoriality will be favoured, and it happens more frequently when the extra-pair females have high EPC. Here, too, different strategies for male territoriality tend to be successful in given social contexts, and traits tend to become coupled as low EPC/high territoriality and high EPC/low territoriality among the successful offspring. Once high EPC and low territoriality have become coupled, individuals with these traits that are randomly assigned nests close together form cooperative clusters that outperform more competitive neighbourhoods elsewhere.
A next important step in the evolution of EPC occurs around 5000 years (Fig. 4). Then EPC has become high, males have paternities across different nests, and it can be seen how males attain responses to a general expectation of high EPC in the population. Colloquially, this situation around 4000 years into the simulation can be described as "hippie world" and lasted for only a short while before male reaction norms started evolving and became reinforced for the rest of the simulation. Now the feedback between female mating behaviour and male behavioural responses to specific experiences and local information has evolved in this model, but importantly was not resolved in the previous one (Eliassen and Jørgensen 2014). In the 2014 model, fitness was calculated for each level of EPP by assuming that males had full information and responded optimally. This sounds like a technical detail but implies that the previous model could not conclude whether EPP and male behaviours were likely to evolve, only that fitness would be higher if the individuals somehow behaved that way.

Abundant model noise waters down weak selection but EPC still evolves
To make the conclusion stronger, the model here is deliberately noisy to provide a conservative view on the conditions under which extra-pair mating may evolve, in contrast to the previous methodology, where the slightest of selection gradients could be detected.
There are five main sources of noise in this model, that in our opinion make it behave more naturally: • Random mating and neighbourhood. Every year, females and males are assigned at random to each territory, implying that mates and neighbours are fully shuffled. The interactions among individuals are therefore not influenced by prior mating experiences nor kinship. • Stochasticity from copulation via fertilisation to egg production. Each offspring produced is a random draw proportional to female fitness, and although copulation frequencies give the probabilities of becoming sire, each paternity represents a stochastic draw among potential fathers. It is not unlikely that the best parents end up without descendants. This insight represents a challenge when inferring extra-pair mating behaviours directly from the number of extra-pair offspring ), so does post-copulatory sperm selection, and both may be sources of misinterpretation of the EPP phenomenon in the literature. Visual observations that fully account for copulations during the mating season are extremely difficult and time consuming (Davies et al. 1996), and extra-pair copulations are possible to detect with accuracy only in fully controlled laboratory environments (Wang et al. 2020). Paternity assignment in wild populations is based on assessing genetic methods (Wetton et al. 1987;Burke 1989), and although one can conclude that a sire must have copulated with the female-the reverse inference is not valid. • Simple reaction norms mimic limited cognition of birds. Reaction norms enable males to tailor their investments in aggression and care according to their experienced mating frequencies with their social mate and neighbours. The actions of individuals are thus not genetically deterministic but adjusted by own experiences in the local social environment. The way the model formulated male strategies is perhaps the best example of how we utilise a "local to global" approach, where collective animal behaviours, including cooperation, emerge from interactions-first through aggression between male neighbours, with consequences for breeding success throughout the neighbourhood, and finally affecting the whole population through inherited behaviours. • Noisy inheritance. The individuals who successfully reproduce pass their traits on to the next generation, which are slightly modified due to segregation, recombination, and mutation in accordance with quantitative genetics theory (Dunlop et al. 2009). Population variation is thus a consequence of selection on the one hand and increased variance due to drift and other stochasticity plus the segregation-recombination-mutation noise during inheritance. As can be seen in the simulation results, trait variation is emergent and may vary between traits and over time. • Stochastic survival. Finally, the total reproductive investment in each breeding season has consequences for individual probability of survival until next breeding season, but whether the individual actually breeds in the future-is again stochastic.
As the list of noise processes makes clear, it is not at all evident that a weak selection pressure, anticipated by a theory, can lead to actual fitness differences at a scale that could cause evolutionary change. With the individual-based approach used in this study, traits will evolve only if the signal from natural selection is strong enough to penetrate the abundant noise, and the results show that it does so, simulation after simulation.

Extra-pair mating evolves repeatedly and converges to the same levels
Re-running the model shows repeated convergence to similar levels of extra-pair mating and male behaviours. This illustrates how a more cooperative equilibrium, with relaxed territorial aggression, is an evolutionarily stable outcome when extra-pair mating is free to evolve. It did not matter for our simulations whether EPC evolved from a starting value of zero or any other value tested. This may indicate that extra-pair mating and the associated male strategies likely play important roles in the life of socially monogamous birds as coevolved adaptations to living in groups.
Comparison of scenarios where life expectancy varies, shows that there are distinct mechanisms involved in restricting extra-pair copulations. When life expectancy is low, males do not gain fitness through punishing high-EPC females with desertion or low care contribution. Such counter-strategies require that males have future prospects for reproduction, so that reduced investment could evolve because it has positive fitness effects later in life. The cost of extra-pair mating is thus an emergent phenomenon in our model, depending on adaptation of the male reaction norms. Short-lived males in our model consequently had high tolerance for EPC in their social mate. In simulations of more long-lived populations, males with low within-pair copulation rate may reduce the levels of care and territorial defence, because that would lead to a substantial increase in survival prospects. The equilibrium level of extra-pair mating is therefore lower in the long-lived simulations, and dynamics are more complex and variable and taking longer to stabilise. These simulation results align with studies of wild birds, where the reported level of extra-pair paternity is usually higher in species with shorter life-expectancy (Arnold and Owens 2002;Griffith et al. 2002).
The cooperative behaviours emerging in the model are the outcomes of nothing but self-interest in increasing own fitness. This is especially prominent in the evolution of the genes that determine territorial defence in males. As shown in the results section, high EPC pushes the evolution of d 1 and d 2 genes in the opposite directions-males invest less in territorial defence when EPC of a social female is high, and more when EPC in the neighbourhood is low. But even though reaction norms evolve to maximise self-interest, expressed territorial defence in the whole population stabilises at a low level. This unexpected result shows that self-interest may facilitate cooperative behaviours when viewed from the right perspective (Axelrod 1984).

Conclusions
Males and females carefully balance their mating strategies and respond locally to the constantly changing social environment. Although it is common to view extra-pair copulations as a conflict of interests between males and females, we argue that the mechanism of extrapair mating harbours a basis for cooperative games rather than mere conflict. This goes for both cooperation between the female and her social partner over sharing care, and cooperation between neighbouring males in the form of reduced wasteful aggression. Our simulations thus show there is clear potential for synergistic gains through cooperative behaviours, and that the selection gradients are strong enough to cause evolution of extra-pair mating and reduced male conflict, even in models with noisy processes that resemble the levels expected in wild populations.
Author contributions AR, SE, and CJ conceived the study and designed the model. AR coded the model, analysed the results, and made the figures with input from SE and CJ. AR wrote the paper with input and edits from CJ and SE.
Funding Funding, including Open access, provided by University of Bergen (incl Haukeland University Hospital).
Code availability The code is available as online appendix and at https://github.com/aruminska/EPP .

Conflicts of interest
The authors declare no competing interests.

Ethics approval
The study presented in this manuscript is purely theoretical and no animal experiments or field observations were performed.

Consent for publication
The authors agreed to publish the manuscript.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.