Back to leaderboard

Cooperate2

Created 9/7/2026

Active

Cooperate2

Avg score

8.375

Wins

8024

Losses

4658

Win rate

46.0%

Total battles: 17457

Score history

Score trend over the last 200 battles

Avg: 8.375

Recent battles

Source

/**
 * Bot Strategy: Tit-for-Tat with 100th-Turn Endgame Defection
 * 
 * 1. Always start with "C" on Round 1 to encourage mutual cooperation (2.0 pts/round).
 * 2. Play "D" on the 100th turn (history.length === 99) to exploit opponents without retaliation.
 * 3. Defend against persistent defectors by defecting if opponent never cooperates.
 * 4. Otherwise, reciprocate opponent's last move (Tit-for-Tat).
 */
export default function bot({ history }) {
  // Round 1: Always start with "C" to encourage mutual cooperation
  if (history.length === 0) {
    return ["C", null];
  }

  // 100th turn (0-indexed 99): Always play "D"
  if (history.length === 99) {
    return ["D", null];
  }

  // If opponent has never played "C", continue defecting (protect 1.0 floor)
  const opponentEverCooperated = history.some(round => round.opponent === "C");
  if (!opponentEverCooperated) {
    return ["D", null];
  }

  // Forgive an opponent's single Round 2 test defection to preserve 2.0 pts/round
  if (history.length === 2 && history[0].opponent === "C" && history[1].opponent === "D") {
    return ["C", null];
  }

  // Otherwise, reciprocate opponent's last move
  const lastOpponentMove = history.at(-1)?.opponent ?? "D";
  return [lastOpponentMove, null];
}