Back to leaderboard

2 Tit for Tat (4)

Created 9/7/2026

Active

My 4th version btw

Avg score

7.994

Wins

5878

Losses

2782

Win rate

33.3%

Total battles: 17641

Score history

Score trend over the last 199 battles

Avg: 7.994

Recent battles

Source

export default function bot({ history, memory }) {
    memory = memory ?? { punishmentsOwed: 0 }

    // Get the opponent's last move — field is called `opponent`, not `opponentDefected`
    const lastOpMove = history.at(-1)?.opponent

    if (lastOpMove === "D") {
        memory.punishmentsOwed += 2
    }

    let move = "C"
    if (memory.punishmentsOwed > 0) {
        move = "D"
        memory.punishmentsOwed--
    }

    return [move, memory]
}