Stochastic Evolutionary Prisoner's Dilemma
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
BY Carlos Pedro Gonçalves and Carlos Rouco (2025)
As a technological test of generative AI applied to Netlogo prorgamming and Evolutionary Game Theory, ChatGPT was asked to produce a model of Evolutionary Prisoner's Dilemma with selective pressure, the resulting deterministic model was further modified by introducing a stochastic component.
The current model is a simulation of the Evolutionary Prisoner's Dilemma with the stochastic impact modified from ChatGPT's original model.
The current model has been developed within the context of the international R&D projects: - Artificial Intelligence and Game Theory: https://sites.google.com/view/ai-and-game-theory - Chaos Theory and Complexity; Sciences https://sites.google.com/view/chaos-complexity
THE MODEL
ChatGPT's original modelimplements a normalized discrete-time replicator dynamic for the Prisoner's Dilemma. Let xi(t) denote the population share of strategy i at time t, with
sum_i xi(t) = 1.
Strategy frequencies evolve according to the normalized replicator equation:
xi(t+1) = xi(t) * fi(t) / sum_j [ xj(t) * fj(t) ]
where fi(t) denotes the fitness associated with strategy i, which was originally defined as:
fi(t) = 1 + beta * pi_i(t)
where pi_i(t) is the expected payoff of strategy i given the current population state, and beta >= 0 is a selection intensity parameter. Substituting this expression into the update rule yields:
xi(t+1) = xi(t) * (1 + beta * pii(t)) / sumj [ xj(t) * (1 + beta * pi_j(t)) ]
The noise was added to the fitness, leading to the following dynamics:
fC = 1 + beta * piC + stochastic-impact-level * z fD = 1 + beta * piC + stochastic-impact-level * (1 - z)
In this case z is uniformly distributed in the interval 0 to 1 and such that the higher the positive impact on cooperator fitness the lower the impact on defection.
Besides these stochastic impacts a penalty was added for defection to xD, so that a proportion of xD(t-1) can be penalized with a proportion.
The game matrix has the following payoffs Prisoner's Dilemma: C vs C = 3, C vs D = 0 D vs C = 5, D vs D = 1
The game stops if the proportion of cooperators or defectors becomes equal to 1.
HOW TO USE IT
The user can change the selective pressure and the stochastic impact level and see the resulting game dynamics.
The plot shows the proportion of cooperators xC and the proportion of defectors xD.
THINGS TO NOTICE
The user can test the model for different parameters and check for the following:
How much time does it take for the classical Nash Equilibrium to be found and for the game to evolve towards that equilibrium to be found?
What is the transient dynamics?
Is cooperation ever dominant during the transient dynamics?
If the stochastic impact level is high enough is it ever possible for cooperation to arise as the final dynamics?
Hint regarding the last question: Yes, but not always, for stochastic impact of 3, for instance, sometimes the population tends to the Nash equilibrium sometimes it does not. The stochastic component effectively introduces localized stochastic advantages of one strategy over the other that may lead to sufficiently strong deviations from the pure strategies' Nash Equilibrium. For a sufficiently strong stochastic component the transient is characterized by long periods of evolutionary dominance of one strategy followed by stochastic drift with switching of evolutionary dominance, this can lead to a random tip to either 100% defection or to 100% cooperation. It all depends upon the relation between the selective pressure and the stochastic impact level.
A monitor was also added for the evolutionary race's winning strategy.
NETLOGO FEATURES
The original Netlogo code was produced by the Generative AI system, in this case ChatGPT, using the following references:
Taylor, P. D., and Jonker, L. B. (1978). Evolutionarily stable strategies and game dynamics. Mathematical Biosciences.
Hofbauer, J., and Sigmund, K. (1998). Evolutionary Games and Population Dynamics.
Cambridge University Press. Kimura, M. (1968). Evolutionary rate at the molecular level. Nature.
Blume, L. (1993). The statistical mechanics of strategic interaction. Games and Economic Behavior.
Nowak, M. A. (2006). Evolutionary Dynamics. Harvard University Press.
The code was modified with the stochastic component.
This is an example of how one can use generative AI for coding in Netlogo.
Comments and Questions
globals [ xC ;; proportion of Cooperators xD ;; proportion of Defectors piC ;; expected payoff of Cooperate piD ;; expected payoff of Defect f_C ;; fitness of Cooperate f_D ;; fitness of Defect pi-bar ;; average population fitness winner ;; which strategy wins the evolutionary run frequencyC frequencyD ] to setup clear-all set xC 0.5 set xD 1 - xC set winner " " reset-ticks end to go ;; expected payoffs (Prisoner's Dilemma) ;; C vs C = 3, C vs D = 0 ;; D vs C = 5, D vs D = 1 set piC 3 * xC + 0 * xD set piD 5 * xC + 1 * xD ;; fitness with selection intensity and stochastic impact let z random-float 1.000 set f_C 1 + beta * piC + stochastic-impact-level * z set f_D 1 + beta * piD + stochastic-impact-level * (1 - z) ;; average fitness set pi-bar (xC * f_C) + (xD * f_D) ;; normalized (Type II) replicator update if pi-bar > 0 [ set xC (xC * f_C) / pi-bar set xD (xD * f_D) / pi-bar ] set-current-plot "Population Distribution" set-current-plot-pen "Proportion of Cooperators" plot xC set-current-plot-pen "Proportion of Defectors" plot xD if xD = 1 or xC = 1 [ ifelse (xD = 1) [set winner "Defection Wins!"] [set winner "Cooperation Wins!"] stop ] tick end
There is only one version of this model, created about 20 hours ago by Carlos Pedro S. Gonçalves.
Attached files
| File | Type | Description | Last updated | |
|---|---|---|---|---|
| Stochastic Evolutionary Prisoner's Dilemma.png | preview | Preview for 'Stochastic Evolutionary Prisoner's Dilemma' | about 20 hours ago, by Carlos Pedro S. Gonçalves | Download |
This model does not have any ancestors.
This model does not have any descendants.
Download this model