Back to leaderboard

something

Created 9/18/2026

Active

idk i was bored

Avg score

7.989

Wins

1138

Losses

1730

Win rate

21.2%

Total battles: 5374

Score history

Score trend over the last 200 battles

Avg: 7.989

Recent battles

Source

export default function bot({ history, memory }) {
    const hLen = history.length
    let mem = memory
    if (mem == null) mem = {tit: 0}
    if (hLen === 0) return ["C", mem]

    let oppDefected = false
    let dCount = 0
    for (let i = 0; i < hLen; i++) {
        if (history[i].opponent === "D") {
            oppDefected = true
            dCount++
        }
    }

    if (oppDefected) {
        let dCountLast5 = 0
        for (let i = hLen-1; i >= Math.max(0, hLen-5); i--) {
            if (history[i].opponent === "D") {
                dCountLast5++
            }
        }
        if (dCount === 1) return ["C", mem]
        if (dCountLast5 === 2) return ["D", mem]
        if (dCountLast5 >= 3) {
            mem.tit = 5
        }
    }

    // tit for tat
    if (mem.tit > 0) mem.tit--
    return [history.at(-1).opponent, mem]
}