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
lIIIIIIlIllllIIl, lIIllllIIIlIllIllI = Action.C, Action.D
class IIIIlIlIll(Player):
    llIIIIlIlIlIlIIIII = "strategy"
    IllIllIllllIII = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(lIllllllIlIllIIl) -> None:
        super().__init__()
        lIllllllIlIllIIl.IIIIIlllIIIIIll = "Normal"
        lIllllllIlIllIIl.IllIlIlIllIIlllIIl = 0
        lIllllllIlIllIIl.lIIIIIIIIIIIlllllI = 0
        lIllllllIlIllIIl.lllllIlI = 0
    def IIllIlIIIllIlI(lIllllllIlIllIIl, IlIlIIlllIIIIl: Player):
        IIIllIIIlIllIlIIII = lIllllllIlIllIIl.match_attributes["game"]
        lIlIIlIIlIIllIIlllII = (lIllllllIlIllIIl.history[-1], IlIlIIlllIIIIl.history[-1])
        llIllIlIlI = IIIllIIIlIllIlIIII.score(lIlIIlIIlIIllIIlllII)
        lIllllllIlIllIIl.lIIIIIIIIIIIlllllI += llIllIlIlI[0]
        lIllllllIlIllIIl.lllllIlI += llIllIlIlI[1]
    def lllIIIlllllI(lIllllllIlIllIIl, IlIlIIlllIIIIl: Player) -> Action:
        IIlIIlllIIIlIlI = len(lIllllllIlIllIIl.history) + 1
        if IIlIIlllIIIlIlI > 1:
            lIllllllIlIllIIl.IIllIlIIIllIlI(IlIlIIlllIIIIl)
        if lIllllllIlIllIIl.IIIIIlllIIIIIll == "Defect":
            return lIIllllIIIlIllIllI
        if lIllllllIlIllIIl.IIIIIlllIIIIIll == "Coop Def Cycle 1":
            lIllllllIlIllIIl.IIIIIlllIIIIIll = "Coop Def Cycle 2"
            return lIIIIIIlIllllIIl
        if lIllllllIlIllIIl.IIIIIlllIIIIIll == "Coop Def Cycle 2":
            lIllllllIlIllIIl.IIIIIlllIIIIIll = "Normal"
            return lIIllllIIIlIllIllI
        if IIlIIlllIIIlIlI % 18 == 0:
            if lIllllllIlIllIIl.IllIlIlIllIIlllIIl >= 3:
                lIllllllIlIllIIl.IllIlIlIllIIlllIIl -= 1
        if IIlIIlllIIIlIlI % 6 != 0:
            return lIIIIIIlIllllIIl
        llIllIIIl = lIllllllIlIllIIl.lIIIIIIIIIIIlllllI / IIlIIlllIIIlIlI  
        if llIllIIIl < 1.0:
            lIllllllIlIllIIl.IllIlIlIllIIlllIIl += 5
        elif llIllIIIl < 1.5:
            lIllllllIlIllIIl.IllIlIlIllIIlllIIl += 3
        elif llIllIIIl < 2.0:
            lIllllllIlIllIIl.IllIlIlIllIIlllIIl += 2
        elif llIllIIIl < 2.5:
            lIllllllIlIllIIl.IllIlIlIllIIlllIIl += 1
        else:
            return lIIIIIIlIllllIIl
        if lIllllllIlIllIIl.IllIlIlIllIIlllIIl >= 7:
            lIllllllIlIllIIl.IIIIIlllIIIIIll = "Defect"
        else:
            lIllllllIlIllIIl.IIIIIlllIIIIIll = "Coop Def Cycle 1"
        return lIIllllIIIlIllIllI