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
IlIllIlllII, lIIllIIlIIlIIIlllII = Action.C, Action.D
class IIIlIIIl(Player):
    lIIlIIIIlllll = "strategy"
    IllIIIIlllIlI = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(lllllIlIll):
        super().__init__()
        lllllIlIll.lIlIIlll = False
        lllllIlIll.lIIIIllllllllIIllll = 0
        lllllIlIll.IllIllllIIllIIIlI = 0
        lllllIlIll.IllIllIIIIIIl = [0] * 12
        lllllIlIll.lIIIIIIIIIIIIllI = 0  
    def lllIllIIIIl(lllllIlIll, lIllIlIIlIIllIIlllll):
        if np.sum(lllllIlIll.IllIllIIIIIIl) >= 5:
            return lIIllIIlIIlIIIlllII
        return lIllIlIIlIIllIIlllll
    def llIlllllllIl(lllllIlIll, llIlIlIllI: Player) -> Action:
        if len(llIlIlIllI.history) == 0:
            return IlIllIlllII
        if len(llIlIlIllI.history) >= 2:
            lllllIlIll.IllIllIIIIIIl[lllllIlIll.lIIIIIIIIIIIIllI] = 0
            if llIlIlIllI.history[-2] == lIIllIIlIIlIIIlllII:
                lllllIlIll.IllIllIIIIIIl[lllllIlIll.lIIIIIIIIIIIIllI] = 1
            lllllIlIll.lIIIIIIIIIIIIllI = (lllllIlIll.lIIIIIIIIIIIIllI + 1) % 12
        if lllllIlIll.lIlIIlll:
            lllllIlIll.lIlIIlll = False
            lllllIlIll.IllIllllIIllIIIlI = 0
            if (
                lllllIlIll.lIIIIllllllllIIllll < len(lllllIlIll.history) + 1
                and llIlIlIllI.history[-1] == lIIllIIlIIlIIIlllII
            ):
                lllllIlIll.lIIIIllllllllIIllll += 20
                return lllllIlIll.lllIllIIIIl(IlIllIlllII)
            else:
                return lllllIlIll.lllIllIIIIl(llIlIlIllI.history[-1])
        else:
            if llIlIlIllI.history[-1] == lIIllIIlIIlIIIlllII:
                lllllIlIll.IllIllllIIllIIIlI += 1
            else:
                if lllllIlIll.IllIllllIIllIIIlI % 2 == 1:
                    lllllIlIll.lIlIIlll = True
                lllllIlIll.IllIllllIIllIIIlI = 0
            return lllllIlIll.lllIllIIIIl(llIlIlIllI.history[-1])