Back to leaderboard

fightAggression

Created 9/16/2026

Active

Has a chance to defect if the opponent is deemed "aggressive". Otherwise peaceful unless provoked.

Avg score

8.336

Wins

458

Losses

2593

Win rate

6.3%

Total battles: 7268

Score history

Score trend over the last 200 battles

Avg: 8.336

Recent battles

Source

export default state => {
  if (!state.history || state.history.length === 0) {
    return ["C", state.memory];
  }

  const lastRound = state.history[state.history.length - 1];
  const opponentLastMove = lastRound.opponent !== undefined ? lastRound.opponent : lastRound[1];

  if (opponentLastMove === "D") {
    // 80% chance to retaliate, 20% chance to forgive
    return [Math.random() < 0.8 ? "D" : "C", state.memory];
  }

  // Opponent's last move was Cooperate. Checks aggressiveness: % of opponent's total moves that were D
  const opponentMoves = state.history.map(round =>
    round.opponent !== undefined ? round.opponent : round[1]
  );
  const defectionCount = opponentMoves.filter(move => move === "D").length;
  const defectionRate = defectionCount / opponentMoves.length;

  const isAggressive = defectionRate > 0.4;

  if (isAggressive) {
    return [Math.random() < 0.4 ? "D" : "C", state.memory];
  }

  return ["C", state.memory];
};