The replicator dynamics were first introduced by Taylor and Jonker (1978) to provide continuous dynamics for evolutionary game theory. The basic idea is that the frequency of a strategy in a population will increase, or decrease, depending on whether the fitness conferred by that strategy is better, or worse, than the average fitness of the population.
This program implements the discrete replicator dynamics for 3 strategies. Let si denote the proportion of the population which follows strategy i = 1, 2, or 3. (Note that it follows that 0 ≤ si ≤ 1 for all i and that s1 + s2 + s3 = 1.)
Let Ui denote the expected utility of strategy i in the population. If we denote the payoff i receives when played against strategy j by σij, then the value of Ui is computed as follows:
The average utility of the population is simply the weighted average of these expected utilities. The weight used is simply the proportion of the population following a strategy:
The discrete replicator dynamics says that the proportion of the population following a strategy will change as follows:
The constant β denotes the background fitness of the population (i.e., something like the default fecundity of individuals). Larger values of β cause the strategy frequencies of the population to change more slowly.
Sometimes we want to introduce a small amount of bias into how people choose others to interact with. (The default assumption is that all pairwise combinations are equally likely.) That is, sometimes we want a person’s partner to be correlated with the strategy used by a person. It is possible — although I won't include the details here as the notation is slightly messier — to introduce correlation into the above equations. A correlation coefficient of ε = 1 means that people only interact with people following the same strategy as themselves; a correlation coefficient of ε = 0 means that interactions are not biased at all. Values between 0 and 1 represent bias of increasingly greater degree.