from axelrod.action import Action, actions_to_str
from axelrod.player import Player
from axelrod.strategy_transformers import (
    FinalTransformer,
    TrackHistoryTransformer,
)
lIIIllIIlIllll, IIIIIIIIIIIllIlIIIlI = Action.C, Action.D
class lIIIllll(Player):
    lIIIlIlIl = "strategy"
    llIIlIIllIllIll = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IlllIlIlllllIIll) -> None:
        super().__init__()
        IlllIlIlllllIIll.IIIIlllIIIlll = 0.25
        IlllIlIlllllIIll.lIlIlllllIIlII: dict = dict()
        IlllIlIlllllIIll.IIlIlllllIIIllllI = ""
        IlllIlIlllllIIll.IllIlIlIlIlIIIllllll = ""
    def IllIIlIIl(IlllIlIlllllIIll, IlIlIlll: Player) -> Action:
        if len(IlllIlIlllllIIll.history) > 5:
            IlllIlIlllllIIll.IIlIlllllIIIllllI = (
                str(IlIlIlll.history[-3])
                + str(IlllIlIlllllIIll.history[-3])
                + str(IlIlIlll.history[-2])
                + str(IlllIlIlllllIIll.history[-2])
            )
            IlllIlIlllllIIll.IllIlIlIlIlIIIllllll = (
                str(IlIlIlll.history[-2])
                + str(IlllIlIlllllIIll.history[-2])
                + str(IlIlIlll.history[-1])
                + str(IlllIlIlllllIIll.history[-1])
            )
            IlllIlIlllllIIll.IlIIlIIIIIIIIIlI(IlIlIlll)
        if (len(IlllIlIlllllIIll.history) < 30) or (
            IlllIlIlllllIIll.IllIlIlIlIlIIIllllll not in IlllIlIlllllIIll.lIlIlllllIIlII
        ):
            if not IlllIlIlllllIIll.history:
                return lIIIllIIlIllll
            if IlIlIlll.history[-1] == IIIIIIIIIIIllIlIIIlI:
                return IIIIIIIIIIIllIlIIIlI
            return lIIIllIIlIllll
        IlIIllIIIlIIlll = IlllIlIlllllIIll.lIlIlllllIIlII[IlllIlIlllllIIll.IllIlIlIlIlIIIllllll]
        IlIIIllIIlIllIIlIl = IlIIllIIIlIIlll.count(lIIIllIIlIllll)
        if (IlIIIllIIlIllIIlIl / len(IlllIlIlllllIIll.history)) > IlllIlIlllllIIll.IIIIlllIIIlll:
            return lIIIllIIlIllll
        return IIIIIIIIIIIllIlIIIlI
    def IlIIlIIIIIIIIIlI(IlllIlIlllllIIll, IlIlIlll: Player):
        if IlllIlIlllllIIll.IIlIlllllIIIllllI in IlllIlIlllllIIll.lIlIlllllIIlII.keys():
            IlIIllIIIlIIlll = IlllIlIlllllIIll.lIlIlllllIIlII[IlllIlIlllllIIll.IIlIlllllIIIllllI]
            IlIIllIIIlIIlll.append(IlIlIlll.history[-1])
            IlllIlIlllllIIll.lIlIlllllIIlII[IlllIlIlllllIIll.IIlIlllllIIIllllI] = IlIIllIIIlIIlll
        else:
            IlllIlIlllllIIll.lIlIlllllIIlII[IlllIlIlllllIIll.IIlIlllllIIIllllI] = [IlIlIlll.history[-1]]