Evolutionary game theory in R
Most of population genetics assumes that a strategy has a fitness. Evolutionary game theory drops that assumption and asks what happens when the payoff to a behaviour depends on what everyone else in the population is doing. The answer changes the shape of the problem: there is no fitness peak to climb, only a moving target set by the current mix of strategies. This page collects every tutorial on this site that builds one of those models by hand in base R, from a single contest over a resource to cooperation on a lattice and drift in a finite population.
Fitness that depends on the opponent
The payoff matrix is the whole apparatus. Two individuals meet, each plays a strategy, and the matrix says what each one gets. Because the population supplies the opponents, the average payoff to a strategy is a function of the strategy frequencies, and that function is what selection sees. Negative frequency dependence, where a strategy does well precisely when it is rare, is the engine behind almost everything on this page: it is what holds a mixed strategy in place, what keeps a sex ratio near parity, and what lets a rare cooperator gain a foothold. The same logic appears in coexistence theory under a different name, which is why the two topics keep meeting.
Stability is several ideas, not one
An evolutionarily stable strategy is defined by an invasion test: a resident that no rare mutant can do better against. That is a static condition, and it is not the same as being the endpoint of a dynamic. The replicator equation supplies the dynamic, and comparing the two exposes the gaps. A strategy can be stable against invasion yet unreachable from most starting points; a cyclic game can circle a rest point forever without settling on it; a coordination game can have several stable outcomes, so that history rather than payoff decides the winner. Being clear about which question is being asked, invasion or convergence, removes most of the confusion in this area.
Cooperation is the hard case
The prisoner’s dilemma is arranged so that defection is the better reply to anything, which makes cooperation an evolutionary puzzle rather than a preference. The escape routes are structural, and each one changes the game rather than the payoffs. Interacting with relatives makes the beneficiary carry copies of the actor’s alleles. Repeating the encounter lets today’s cooperation buy tomorrow’s. Watching third parties lets reputation stand in for personal experience. Putting individuals on a lattice or a graph lets cooperators cluster and shelter each other. Splitting a population into groups makes selection act at more than one level. Each route has its own threshold condition, and the conditions are structurally similar enough that seeing them side by side is more instructive than any one of them alone.
Small populations break the deterministic story
Replicator dynamics describe an infinite, well-mixed population. Real ones are neither. In a finite population a mutant can fix by chance even when selection is against it, and can be lost even when selection favours it, so the honest question is not whether a strategy wins but how probable fixation is. That shift also changes what stability means: a strategy can be resistant to invasion by the standard test and still be the less likely of two to take over. Letting mutations be small rather than arbitrary gives a third view again, in which a population climbs a fitness gradient until it reaches a point that is attracting and yet not stable, and a single lineage splits in two.
The tutorials
Evolutionary game theory
- The hawk-dove game and the ESS - the classic contest over a resource, and the mixed strategy no mutant can beat.
- The replicator equation - turning a payoff matrix into a dynamic, and what the trajectories do that the ESS test cannot say.
- Sex ratio evolution and the ESS - Fisher’s argument as a game against the rest of the population, and the conditions that break it.
- Checking a game theory model - how far the conclusion survives a change of payoffs, of population size, and of starting mix.
The evolution of cooperation
- The prisoner’s dilemma - building the payoff structure that makes defection the better reply to everything.
- Direct reciprocity and tit-for-tat - what repetition buys, and the continuation probability that decides whether it is enough.
- Strategies in the iterated game - a tournament between memory-one strategies, and the bistability the winners live in.
- Checking a reciprocity model - mistakes, partner turnover, and the assumptions a repeated game quietly needs.
Indirect reciprocity and reputation
- Indirect reciprocity and reputation - helping a stranger because someone is watching, and the condition that makes it pay.
- Assessment rules for reputation - the standard ways of judging a refusal to help, compared on one simulation.
- Public and private reputation - what happens to each rule once observers disagree about who is good.
- Checking a reputation model - the sensitivities that decide a reputation result, and the ones that only look decisive.
Network reciprocity and spatial games
- Network reciprocity on a lattice - giving individuals neighbours instead of a well-mixed crowd, and watching clusters form.
- Update rules and cooperation on graphs - why the rule for who copies whom matters as much as the game itself.
- Multilevel selection and group structure - selection between groups against selection within them, and the sign reversal that follows.
- Checking a spatial cooperation model - the conventions of a lattice simulation, and which of them the answer depends on.
Finite populations and gradual evolution
- The Moran process and fixation probability - one birth and one death at a time, with an exact fixation probability and a waiting time.
- Evolutionary games in finite populations - frequency dependence with drift, and two invasion thresholds that do not coincide.
- Adaptive dynamics and evolutionary branching - invasion fitness, pairwise invasibility plots, and the point where a lineage splits.
- Checking a finite population model - the replication a stochastic estimate needs, and the scaling that makes weak selection comparable.
Where this connects
- Quantitative genetics in R supplies the accounting behind kin selection and the response to selection that these games leave implicit.
- Species coexistence in R runs on the same negative frequency dependence, with species in place of strategies.
- Population models in R provides the demography that a game-theoretic payoff is standing in for.
- Ecological time series in R reads the cycles and tipping behaviour that game dynamics produce.