add explanation

This commit is contained in:
Didictateur 2026-07-25 22:48:51 +02:00
parent 87abce2ffc
commit 28924f4516

View file

@ -88,6 +88,32 @@ font-size: 14px;
width: 50px;
font-size: 14px;
}
#explanation {
max-width: 700px;
margin-top: 40px;
font-size: 14px;
line-height: 1.6;
}
#explanation h2 {
font-size: 18px;
margin-bottom: 6px;
}
#explanation h3 {
font-size: 15px;
margin-bottom: 4px;
}
#explanation ul {
margin-top: 4px;
padding-left: 20px;
}
#explanation li {
margin-bottom: 4px;
}
</style>
</head>
<body>
@ -122,6 +148,62 @@ font-size: 14px;
</div>
</div>
<div id="explanation">
<h2>Explanation</h2>
<p>
This grid simulates an iterated prisoner's dilemma played across a population of cells.
Each cell represents an agent applying a strategy and playing against its immediate
neighbors at every step ("Step"). Depending on the results obtained, a cell may adopt
the strategy of a better-performing neighbor, which causes the distribution of colors
to evolve over successive steps.
</p>
<h3>Parameters (payoff matrix)</h3>
<ul>
<li><strong>T (temptation)</strong>: payoff for defecting against an opponent who cooperates.</li>
<li><strong>R (reward)</strong>: payoff when both players cooperate.</li>
<li><strong>P (punishment)</strong>: payoff when both players defect.</li>
<li><strong>S (sucker)</strong>: payoff for cooperating against an opponent who defects.</li>
</ul>
<p>
For the dilemma to be valid, the order T &gt; R &gt; P &gt; S must hold. But it doesn't prevent you to have fun with those.
</p>
<h3>Strategies</h3>
<ul>
<li><strong>Always Cooperate</strong>: cooperates systematically, regardless of the opponent's behavior.</li>
<li><strong>Always Defect</strong>: defects systematically.</li>
<li><strong>Random</strong>: chooses randomly between cooperation and defection at each interaction.</li>
<li><strong>Tit-for-Tat</strong>: cooperates on the first move, then repeats the opponent's last move.</li>
<li><strong>Suspicious Tit-for-Tat</strong>: identical to Tit-for-Tat, but defects on the first move.</li>
<li><strong>Grim Trigger</strong>: cooperates as long as the opponent cooperates, but defects permanently after the opponent's first defection.</li>
<li><strong>Majority</strong>: reproduces the opponent's majority behavior over the history of previous moves.</li>
</ul>
<h3>Usage</h3>
<ul>
<li>The checkboxes in the legend select which strategies are included on "Reset".</li>
<li>The "Step" button advances the simulation by one step (holding it down repeats the operation automatically).</li>
<li>The "Reset" button reinitializes the grid with the selected strategies.</li>
</ul>
<h3>Why cooperation emerges here</h3>
<p>
In the classic single-shot, two-player prisoner's dilemma, defection is the dominant
strategy: whatever the opponent does, defecting yields a better payoff, so rational
players end up at the mutual-defection outcome (P, P) even though mutual cooperation
(R, R) would leave both better off. This grid nonetheless shows sizable pockets of
cooperation surviving and even spreading. Two features of the setup explain the
difference. First, the game is repeated rather than played once, so strategies such
as Tit-for-Tat or Grim Trigger can punish defection in future rounds, which removes
the incentive to defect that exists in a single, isolated encounter. Second, agents
only interact with their local neighbors and imitate nearby strategies that perform
well, so clusters of cooperators can support each other and outcompete an isolated
defector, even though a defector still beats an individual cooperator in a single
pairwise match.
</p>
</div>
<script src="main.js"></script>
<script>