from typing import List
import numpy as np
from axelrod.action import Action
from axelrod.interaction_utils import compute_final_score
from axelrod.player import Player
from axelrod.strategies.finite_state_machines import FSMPlayer
IIIIIlIllIIlIIII, IIlllllIlIlIIIIIl = Action.C, Action.D
class llllllIllIlIlI(Player):
    llIIIlllIIlll = "strategy"
    IlIIIIII = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IIIllIIlIllII) -> None:
        super().__init__()
        IIIllIIlIllII.IIIIIIIIllIllI = 2
        IIIllIIlIllII.IlIIIlIlIIllIl = [1] * 4
        IIIllIIlIllII.lIllIllllII = 0
        IIIllIIlIllII.llIIllIlIIllIlllllII = 21
        IIIllIIlIllII.IllIIIIIIllllIIl = 2
        IIIllIIlIllII.IllIIlIIlI = float("inf")
        IIIllIIlIllII.IlllIlllllIIllllIll = 2
        IIIllIIlIllII.IIIIllII = 2
    def lllIllllIlllIl(IIIllIIlIllII, IIllllIIlllIlIIIIl: Player) -> Action:
        IIIIIIllllIlllIIllI = len(IIIllIIlIllII.history) + 1
        if IIIIIIllllIlllIIllI == 1:
            return IIIIIlIllIIlIIII
        IIIllIIlIllII.lIllIllllII = (IIIllIIlIllII.lIllIllllII + 1) % 4
        IIlIlIlIIllIlIIlIIl = IIIIIlIllIIlIIII
        if IIIIIIllllIlllIIllI > 2:
            IIlIlIlIIllIlIIlIIl = IIIllIIlIllII.history[-2]
        if IIlIlIlIIllIlIIlIIl == IIllllIIlllIlIIIIl.history[-1]:
            IIIllIIlIllII.IIIIIIIIllIllI += 1
            IIIllIIlIllII.IlIIIlIlIIllIl[IIIllIIlIllII.lIllIllllII] = 1
        else:
            IIIllIIlIllII.IlIIIlIlIIllIl[IIIllIIlIllII.lIllIllllII] = 0
        if IIIIIIllllIlllIIllI < IIIllIIlIllII.IllIIlIIlI:
            if IIllllIIlllIlIIIIl.history[-1] == IIIIIlIllIIlIIII:
                IIIllIIlIllII.IllIIIIIIllllIIl += 1
            else:
                IIIllIIlIllII.IllIIIIIIllllIIl = 0
            if IIIllIIlIllII.IllIIIIIIllllIIl >= IIIllIIlIllII.llIIllIlIIllIlllllII:
                IIIllIIlIllII.IllIIlIIlI = IIIIIIllllIlllIIllI
                if IIIllIIlIllII.IllIIIIIIllllIIl == IIIllIIlIllII.llIIllIlIIllIlllllII:
                    return IIlllllIlIlIIIIIl
        elif IIIIIIllllIlllIIllI == IIIllIIlIllII.IllIIlIIlI + 2:
            IIIllIIlIllII.IllIIlIIlI = float("inf")
            if IIllllIIlllIlIIIIl.history[-1] == IIIIIlIllIIlIIII:
                IIIllIIlIllII.IlllIlllllIIllllIll += 1
            else:
                IIIllIIlIllII.IIIIllII += 1
            IIIllIIlIllII.llIIllIlIIllIlllllII = (
                np.floor(
                    20.0 * IIIllIIlIllII.IIIIllII / IIIllIIlIllII.IlllIlllllIIllllIll
                )
                + 1
            )
            IIIllIIlIllII.IllIIIIIIllllIIl = 0
            return IIIIIlIllIIlIIII
        IlIIlIlIlIlI = IIIllIIlIllII.IIIIIIIIllIllI / IIIIIIllllIlllIIllI
        IIlIlIIllIIII = sum(IIIllIIlIllII.IlIIIlIlIIllIl)
        if IlIIlIlIlIlI > 0.9 and IIlIlIIllIIII >= 4:
            return IIIIIlIllIIlIIII
        elif IlIIlIlIlIlI >= 0.625 and IIlIlIIllIIII >= 2:
            return IIllllIIlllIlIIIIl.history[-1]
        return IIlllllIlIlIIIIIl