Back to leaderboard

AVIZAT

Created 9/8/2026

Active

my new bot

Avg score

7.002

Wins

5653

Losses

7565

Win rate

33.8%

Total battles: 16725

Score history

Score trend over the last 199 battles

Avg: 7.002

Recent battles

Source

export default function bot({ history, memory }) {
  const currentRound = history.length

  // Initialize memory on round 0
  if (!memory) {
    memory = { opponentType: "UNKNOWN" }
  }

  // --- 1. Opening Test Sequence ---
  // Round 0: Cooperate
  if (currentRound === 0) return ["C", memory]
  // Round 1: Defect to probe reaction
  if (currentRound === 1) return ["D", memory]
  // Round 2: Cooperate to check if opponent retaliates
  if (currentRound === 2) return ["C", memory]

  // --- 2. Classify Opponent after Test Sequence ---
  if (currentRound === 3 && memory.opponentType === "UNKNOWN") {
    const opp0 = history[0].opponent
    const opp1 = history[1].opponent
    const opp2 = history[2].opponent

    // Always Cooperate / Naive bot -> EXPLOIT
    if (opp0 === "C" && opp1 === "C" && opp2 === "C") {
      memory.opponentType = "SUCKER"
    } 
    // Always Defect / Aggressive bot -> DEFECT
    else if (opp1 === "D" && opp2 === "D") {
      memory.opponentType = "DEFECTOR"
    } 
    // Reactive / Tit-for-Tat bot -> TIT_FOR_TAT
    else {
      memory.opponentType = "TIT_FOR_TAT"
    }
  }

  // --- 3. Execute Strategy based on Opponent Profile ---
  
  // Rule A: Fully exploit naive cooperative bots
  if (memory.opponentType === "SUCKER") {
    return ["D", memory]
  }

  // Rule B: Always defect against hard defectors
  if (memory.opponentType === "DEFECTOR") {
    return ["D", memory]
  }

  // Rule C: Generous Tit-For-Tat against responsive/unknown bots
  const lastOpponentMove = history[currentRound - 1].opponent

  if (lastOpponentMove === "D") {
    // 10% chance to forgive defection to break noise/retaliation loops
    if (Math.random() < 0.10) {
      return ["C", memory]
    }
    return ["D", memory]
  }

  return ["C", memory]
}