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
IIlIIIIIIlIlll, lIlIlIllIlll = Action.C, Action.D
class IIIlIIIllIIllIIIIlIl(Player):
    IllllIlI = "strategy"
    IIIIIIllI = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IlIIIlIlIlllllI) -> None:
        super().__init__()
        IlIIIlIlIlllllI.lIlIlIlIlIllIIlIlllI = 0
        IlIIIlIlIlllllI.lIllIIlll = 0
        IlIIIlIlIlllllI.lIIlIIlllI = 0
        IlIIIlIlIlllllI.IlIIlllIlII = False
        IlIIIlIlIlllllI.lIlIIlIIlIlIIII = 0
        IlIIIlIlIlllllI.llllIlIIIIIl = 0
    def IllllllllllIlIIll(IlIIIlIlIlllllI):
        IlIIIlIlIlllllI.lIlIlIlIlIllIIlIlllI = 0
        IlIIIlIlIlllllI.lIllIIlll = 0
        IlIIIlIlIlllllI.lIlIIlIIlIlIIII = 0
        IlIIIlIlIlllllI.llllIlIIIIIl = 0
    def IIlllllII(IlIIIlIlIlllllI, llIlllIIl: Player):
        lIlIIIIlIlIlIlIll = IlIIIlIlIlllllI.match_attributes["game"]
        llIlIIlIlIIlI = (IlIIIlIlIlllllI.history[-1], llIlllIIl.history[-1])
        lIIIIllIlI = lIlIIIIlIlIlIlIll.score(llIlIIlIlIIlI)
        IlIIIlIlIlllllI.lIlIlIlIlIllIIlIlllI += lIIIIllIlI[0]
        IlIIIlIlIlllllI.lIllIIlll += lIIIIllIlI[1]
    def IllllIIlII(IlIIIlIlIlllllI, llIlllIIl: Player) -> Action:
        llIlllllI = len(IlIIIlIlIlllllI.history) + 1
        if llIlllllI == 1:
            return IIlIIIIIIlIlll
        IlIIIlIlIlllllI.IIlllllII(llIlllIIl)
        if IlIIIlIlIlllllI.IlIIlllIlII:
            IlIIIlIlIlllllI.IllllllllllIlIIll()
            IlIIIlIlIlllllI.lIIlIIlllI = llIlllllI
            IlIIIlIlIlllllI.IlIIlllIlII = False
            return IIlIIIIIIlIlll  
        IlIlIIIIIIIIll = False
        lIllIIlIIIIl = IIlIIIIIIlIlll  
        if len(llIlllIIl.history) >= 2:
            lIllIIlIIIIl = llIlllIIl.history[-2]
        if lIllIIlIIIIl == IIlIIIIIIlIlll and llIlllIIl.history[-1] == lIlIlIllIlll:
            IlIlIIIIIIIIll = True
            IlIIIlIlIlllllI.lIlIIlIIlIlIIII += IlIIIlIlIlllllI.llllIlIIIIIl
            IlIIIlIlIlllllI.llllIlIIIIIl += 5
        if IlIIIlIlIlllllI.lIlIlIlIlIllIIlIlllI - IlIIIlIlIlllllI.lIllIIlll >= IlIIIlIlIlllllI.lIlIIlIIlIlIIII:
            return IIlIIIIIIlIlll
        if (not IlIlIIIIIIIIll) and llIlllllI - IlIIIlIlIlllllI.lIIlIIlllI >= 10:
            IllllllIlllIIlI = llIlllIIl.cooperations + llIlllIIl.defections
            IIIllIlllllI = (IllllllIlllIIlI ** (1 / 2)) / 2
            lIIllllIllIlllIlllI = IllllllIlllIIlI / 2 - 3 * IIIllIlllllI
            lIIllIllII = IllllllIlllIIlI / 2 + 3 * IIIllIlllllI
            if llIlllIIl.defections <= lIIllllIllIlllIlllI or llIlllIIl.defections >= lIIllIllII:
                IlIIIlIlIlllllI.IlIIlllIlII = True
                return IIlIIIIIIlIlll  
        return lIlIlIllIlll