Back to leaderboard

IDK Bot

Created 9/7/2026

Active

A simple strategy

Avg score

7.649

Wins

3866

Losses

8658

Win rate

21.9%

Total battles: 17648

Score history

Score trend over the last 200 battles

Avg: 7.649

Recent battles

Source

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

    // Round 1: always cooperate. Never be the first to defect.
    if (round === 0) {
        return ["C", { oppDefections: 0, myDefections: 0 }]
    }

    memory = memory ?? { oppDefections: 0, myDefections: 0 }
    const last = history[round - 1]
    const oppLast = last.opponent

    if (oppLast === "D") memory.oppDefections++

    const oppDefectRate = memory.oppDefections / round
    let move

    if (round >= 15 && memory.oppDefections === 0) {
        // Very likely an always-cooperate bot after enough rounds of evidence.
        // Exploit it — 3 points/round beats the 2 we'd get from mutual cooperation.
        move = "D"
    } else if (round >= 10 && oppDefectRate > 0.85) {
        // Very likely an always-defect (or near it) bot. Stop trying to
        // reciprocate cooperation that never comes — just defect back.
        move = "D"
    } else if (oppLast === "D") {
        // Tit-for-tat retaliation, but generous: forgive occasionally so a
        // single defection (or misread) doesn't lock us into permanent
        // mutual defection, which is worse for both sides long-term.
        move = Math.random() < 0.1 ? "C" : "D"
    } else {
        move = "C"
    }

    return [move, memory]
}