xxxxxxxxxx
function setup() {
createCanvas(800, 400);
textSize(32);
textAlign(CENTER, CENTER);
}
function draw() {
background(240);
let prisonerA = sin(frameCount * 0.05) > 0 ? "C" : "B";
let prisonerB = cos(frameCount * 0.04) > 0 ? "C" : "B";
fill(0);
text("Prisoner A: " + prisonerA, width * 0.25, height / 2);
text("Prisoner B: " + prisonerB, width * 0.75, height / 2);
let outcome = "";
if (prisonerA === "C" && prisonerB === "C") {
outcome = "Mutual Cooperation";
} else if (prisonerA === "B" && prisonerB === "B") {
outcome = "Mutual Betrayal";
} else if (prisonerA === "C" && prisonerB === "B") {
outcome = "A loses, B wins";
} else {
outcome = "B loses, A wins";
}
text("Outcome: " + outcome, width / 2, height * 0.75);
}