This is a spatial evolutionary sandbox based on the Iterated Prisoner's Dilemma (IPD). Cells interact, score points, and evolve over generations via a genetic algorithm.
1. The Dilemma
Every generation, each cell plays a series of matches against its adjacent neighbors. In a match, a cell can either Cooperate (C) or Betray (B).
Mutual Peace: Both Cooperate = 3 points each.
Temptation/Sucker: One Betrays, One Cooperates = 5 points to Betrayer, 0 to Sucker.
Mutual Spite: Both Betray = 1 point each.
2. The Genome & Red-Blue Palette
Each cell has a DNA sequence of 5 floating-point numbers between 0% and 100%. These numbers dictate the probability of cooperating based on the previous round's outcome. The cell's color is a direct map of its strategy:
Gene 0 (Initial Trust): First move of a match.
Gene 1 (Mutual Peace): Response to Mutual Cooperation (CC).
Gene 2 (Forgiveness): Response to being betrayed after cooperating (CB).
Gene 3 (Exploitation): Response to successfully betraying a cooperator (BC).
Gene 4 (Spite): Response to Mutual Betrayal (BB).
Cells that trend towards hostility (exploiting/spiting) turn Dark Red. Cells that are peaceful (cooperating/forgiving) turn Blue. Highly trusting and retaliatory hybrid strategies (like Tit-for-Tat) blend into Purple.
Dark Red: Hostile / Always Defect
Blue: Peaceful / Always Cooperate
Purple: Tit-for-Tat / Responsive
Black Void: Dead / Starved Area
Grey Walls: Environmental Barrier
3. Evolution, Starvation, and Aging
After matches conclude, cells reproduce. A cell looks at its 8 neighbors. The neighbor with the highest score overwrites the cell with its DNA.
Crossover: If the top two neighbors have scores within the Tolerance threshold, the new cell inherits a 50/50 blend of their genes.
Mutation: Offspring genes have a chance to drift slightly, ensuring new strategies can emerge.
Starvation: If no neighbor achieves a score above the Starvation Threshold, the cell dies and leaves behind an empty black void.
Aging: If a cell successfully survives and defends its territory round after round, it will eventually hit the Max Age limit and pass away naturally, leaving space for new strategies to colonize.