from typing import Optional
from axelrod.action import Action
from axelrod.player import Player
lIIIlIIIllIIII, IIIlllll = Action.C, Action.D
class lIlIlIIlIllllIllIII(Player):
    IllIIIlIIlllIIllII = "strategy"
    IllIIlIlIllll = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IIlllllIIIl) -> None:
        super().__init__()
        IIlllllIIIl.lIIIlIIIIIlIII = None  
    def IlIIIIlIIIll(IIlllllIIIl, IlIIIllIll: Player) -> Action:
        if len(IIlllllIIIl.history) < 6:
            return IIIlllll if IlIIIllIll.history[-1:] == [IIIlllll] else lIIIlIIIllIIII
        if len(IIlllllIIIl.history) % 6 == 0:
            if IlIIIllIll.history[-6:] == [lIIIlIIIllIIII] * 6:
                IIlllllIIIl.lIIIlIIIIIlIII = "Cooperative"
            if IlIIIllIll.history[-6:] == [IIIlllll] * 6:
                IIlllllIIIl.lIIIlIIIIIlIII = "ALLD"
            if IlIIIllIll.history[-6:] == [IIIlllll, lIIIlIIIllIIII, IIIlllll, lIIIlIIIllIIII, IIIlllll, lIIIlIIIllIIII]:
                IIlllllIIIl.lIIIlIIIIIlIII = "STFT"
            if IlIIIllIll.history[-6:] == [IIIlllll, IIIlllll, lIIIlIIIllIIII, IIIlllll, IIIlllll, lIIIlIIIllIIII]:
                IIlllllIIIl.lIIIlIIIIIlIII = "PavlovD"
            if not IIlllllIIIl.lIIIlIIIIIlIII:
                IIlllllIIIl.lIIIlIIIIIlIII = "Random"
        if IIlllllIIIl.lIIIlIIIIIlIII in ["Random", "ALLD"]:
            return IIIlllll
        if IIlllllIIIl.lIIIlIIIIIlIII == "STFT":
            if len(IIlllllIIIl.history) % 6 in [0, 1]:
                return lIIIlIIIllIIII
            if IlIIIllIll.history[-1:] == [IIIlllll]:
                return IIIlllll
        if IIlllllIIIl.lIIIlIIIIIlIII == "PavlovD":
            if len(IIlllllIIIl.history) % 6 == 0:
                return IIIlllll
        if IIlllllIIIl.lIIIlIIIIIlIII == "Cooperative":
            if IlIIIllIll.history[-1:] == [IIIlllll]:
                return IIIlllll
        return lIIIlIIIllIIII