from typing import Optional
from axelrod.action import Action
from axelrod.player import Player
lIIllIlIllIlI, lIIIlIIlll = Action.C, Action.D
class IlllIlIIlllIllll(Player):
    lIlIllllllII = "strategy"
    IllllIIIIllIII = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(lllIlllIIllll) -> None:
        super().__init__()
        lllIlllIIllll.IlIIIlIlIl = None  
    def lIllllIIIII(lllIlllIIllll, lllIlIlllllllIIllIlI: Player) -> Action:
        if len(lllIlllIIllll.history) < 6:
            return lIIIlIIlll if lllIlIlllllllIIllIlI.history[-1:] == [lIIIlIIlll] else lIIllIlIllIlI
        if len(lllIlllIIllll.history) % 6 == 0:
            if lllIlIlllllllIIllIlI.history[-6:] == [lIIllIlIllIlI] * 6:
                lllIlllIIllll.IlIIIlIlIl = "Cooperative"
            if lllIlIlllllllIIllIlI.history[-6:].count(lIIIlIIlll) >= 4:
                lllIlllIIllll.IlIIIlIlIl = "ALLD"
            if lllIlIlllllllIIllIlI.history[-6:].count(lIIIlIIlll) == 3:
                lllIlllIIllll.IlIIIlIlIl = "STFT"
            if not lllIlllIIllll.IlIIIlIlIl:
                lllIlllIIllll.IlIIIlIlIl = "Random"
        if lllIlllIIllll.IlIIIlIlIl in ["Random", "ALLD"]:
            return lIIIlIIlll
        if lllIlllIIllll.IlIIIlIlIl == "STFT":
            return lIIIlIIlll if lllIlIlllllllIIllIlI.history[-2:] == [lIIIlIIlll, lIIIlIIlll] else lIIllIlIllIlI
        if lllIlllIIllll.IlIIIlIlIl == "Cooperative":
            return lIIIlIIlll if lllIlIlllllllIIllIlI.history[-1:] == [lIIIlIIlll] else lIIllIlIllIlI