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 llIIIlIIIlIllIllll
IlIIIIllIIlIlI, IlllIlllIllIIIIllll = Action.C, Action.D
class llIIIlIIIlIllIllll(Player):
    llIIllIIIIlllllllIII = "strategy"
    lIIlllllIlIl: Dict[Text, Any] = {
        "memory_depth": 1,
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        lllIllIII,
        llllIlIIl: Tuple[Transition, ...] = ((1, IlIIIIllIIlIlI, 1, IlIIIIllIIlIlI), (1, IlllIlllIllIIIIllll, 1, IlllIlllIllIIIIllll)),
        IIIllllIIlIIlIIIll: int = 1,
        lllIIllIlIllllIIlIl: Action = IlIIIIllIIlIlI,
    ) -> None:
        Player.__init__(lllIllIII)
        lllIllIII.IIIllllIIlIIlIIIll = IIIllllIIlIIlIIIll
        lllIllIII.lllIIllIlIllllIIlIl = lllIIllIlIllllIIlIl
        lllIllIII.llIIlIIIlllll = SimpleFSM(llllIlIIl, IIIllllIIlIIlIIIll)
    def IlIIlIIIlIIIll(lllIllIII, llllllIIIIIl: Player) -> Action:
        if len(lllIllIII.history) == 0:
            return lllIllIII.lllIIllIlIllllIIlIl
        else:
            return lllIllIII.llIIlIIIlllll.move(llllllIIIIIl.history[-1])
class IllIIlllIllI(llIIIlIIIlIllIllll):
    llIIllIIIIlllllllIII = "strategy"
    lIIlllllIlIl = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(lllIllIII) -> None:
        super().__init__()
        lllIllIII.IlllIIIIllllIIlI = 7
    def IlIIlIIIlIIIll(lllIllIII, llllllIIIIIl: Player) -> Action:
        lIIIlIlI = len(lllIllIII.history) + 1
        if lIIIlIlI == 1:
            return IlIIIIllIIlIlI
        if llllllIIIIIl.history[-1] == IlIIIIllIIlIlI:
            lllIllIII.IlllIIIIllllIIlI += 1
            if lllIllIII.IlllIIIIllllIIlI > 8:
                lllIllIII.IlllIIIIllllIIlI = 8
        else:
            lllIllIII.IlllIIIIllllIIlI -= 2
            if lllIllIII.IlllIIIIllllIIlI < -7:
                lllIllIII.IlllIIIIllllIIlI = -7
        if lIIIlIlI == 2:
            return IlIIIIllIIlIlI
        if lllIllIII.IlllIIIIllllIIlI > 0:
            return IlIIIIllIIlIlI
        if lIIIlIlI <= 10:
            lllIllIII.IlllIIIIllllIIlI = 4
            return IlllIlllIllIIIIllll
        if llllllIIIIIl.defections / lIIIlIlI >= 0.15:
            return IlllIlllIllIIIIllll
        return IlIIIIllIIlIlI