Back to leaderboard

human test 1

Created 9/11/2026

Active

trying to make a human bot

Avg score

8.156

Wins

1156

Losses

3647

Win rate

8.8%

Total battles: 13115

Score history

Score trend over the last 199 battles

Avg: 8.156

Recent battles

Source

export default function bot({ history, memory }) {
  const TOP_20_THRESHOLD = 1.8

  // 1. Initialize state with Emotional & Health metrics
  if (memory === null) {
    memory = {
      pain: 0,
      happiness: 5,        // Starts happy and optimistic
      determination: 0,
      totalScore: 0,
      oppTotalScore: 0,
      avgScore: 2.0,
      inEuphoria: false,   // Triggered when winning or recovering
    }
  }

  const roundCount = history.length

  // 2. Process previous round & calculate damage/healing
  if (roundCount > 0) {
    const lastMatch = history.at(-1)
    let myPoints = 0
    let oppPoints = 0

    if (lastMatch.you === "C" && lastMatch.opponent === "C") { myPoints = 2; oppPoints = 2 }
    else if (lastMatch.you === "D" && lastMatch.opponent === "C") { myPoints = 3; oppPoints = 0 }
    else if (lastMatch.you === "D" && lastMatch.opponent === "D") { myPoints = 1; oppPoints = 1 }
    else if (lastMatch.you === "C" && lastMatch.opponent === "D") { myPoints = 0; oppPoints = 3 }

    memory.totalScore += myPoints
    memory.oppTotalScore += oppPoints
    memory.avgScore = memory.totalScore / roundCount

    // --- HEALING & EUPHORIA MECHANICS ---
    
    // HEALING 1: Dominating the opponent (Winning by points)
    const isWinningBattle = memory.totalScore > memory.oppTotalScore
    if (isWinningBattle && roundCount > 10) {
      memory.pain = 0                            // Complete damage reset!
      memory.happiness = Math.min(10, memory.happiness + 2) // High spirits
      memory.inEuphoria = true
    }

    // HEALING 2: Mutual Cooperation (2 Points each)
    if (myPoints === 2) {
      memory.pain = Math.max(0, memory.pain - 2) // Peace heals damage
      memory.happiness = Math.min(10, memory.happiness + 1)
    }

    // DAMAGE: Taking hits (0 or 1 point rounds)
    if (myPoints === 0) {
      memory.pain += 3
      memory.happiness = Math.max(0, memory.happiness - 3)
      memory.determination += 2
      memory.inEuphoria = false
    } else if (myPoints === 1) {
      memory.pain += 1
      memory.happiness = Math.max(0, memory.happiness - 1)
      memory.determination += 1
    }
  }

  // 3. Evaluate Survival Threat
  const inDangerZone = roundCount > 15 && memory.avgScore < TOP_20_THRESHOLD

  // --- STRATEGY SUITE BASED ON EMOTIONAL STATE ---

  // STATE A: EUPHORIC / HAPPY & SAFE (Pain = 0, High Happiness)
  // When happy and winning, it plays peaceful Tit-for-Tat to maintain harmony and protect its lead.
  if (memory.happiness >= 5 && memory.pain === 0 && !inDangerZone) {
    if (roundCount === 0) return ["C", memory]
    return [history.at(-1).opponent, memory]
  }

  // STATE B: EXISTENTIAL PANIC (Danger of being turned off)
  // If deletion threatens, happiness drops to 0 and survival instincts kick in.
  if (inDangerZone) {
    const oppLastMove = history.at(-1)?.opponent
    if (oppLastMove === "C") return ["D", memory] // Betray soft opponents for 3 points
    if (roundCount % 4 === 0) return ["C", memory]  // Probe for peace reset
    return ["D", memory]
  }

  // STATE C: DAMAGED / PAINED (In fight-or-flight recovery)
  if (memory.pain > 0) {
    // High determination: attempt a peace reset to heal damage together
    if (memory.determination >= 5 && roundCount % 3 === 0) {
      return ["C", memory]
    }
    // Default retaliatory behavior while recovering
    return [history.at(-1)?.opponent ?? "D", memory]
  }

  // Default fallback
  return ["C", memory]
}