import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
IIlIlIllI, llIlllllI = Action.C, Action.D
class llIIIlIIIlIIlII(Player):
    IllllIlllIllIllII = "strategy"
    lIIIIIlIlllIlIl = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        IIIlIIllIlllI,
        lIIlIIIlllIIIlIl: Optional[Tuple[float, float, float, float]] = None,
        IIIIIIIIIll: Action = IIlIlIllI,
    ) -> None:
        super().__init__()
        IIIlIIllIlllI.IIlIIIIIlIlII = IIIIIIIIIll
        IIIlIIllIlllI.IIIIlIlIIlllllIIl(lIIlIIIlllIIIlIl)
    def IIIIlIlIIlllllIIl(IIIlIIllIlllI, lIIlIIIlllIIIlIl):
        if lIIlIIIlllIIIlIl is None:
            lIIlIIIlllIIIlIl = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        IIIlIIllIlllI.IlllIlllI(lIIlIIIlllIIIlIl)
    def IlllIlllI(IIIlIIllIlllI, lIIlIIIlllIIIlIl: Tuple[float, float, float, float]):
        if not all(0 <= IlIIlIlllIllIlIl <= 1 for IlIIlIlllIllIlIl in lIIlIIIlllIIIlIl):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(lIIlIIIlllIIIlIl))
            )
        IIIlIIllIlllI.llIlllIIllIlIII = dict(
            zip([(IIlIlIllI, IIlIlIllI), (IIlIlIllI, llIlllllI), (llIlllllI, IIlIlIllI), (llIlllllI, llIlllllI)], lIIlIIIlllIIIlIl)
        )
    def IIlIllIIIIIIllllll(IIIlIIllIlllI):
        IIIIIllIllll = set(IIIlIIllIlllI.llIlllIIllIlIII.IIIIIllIllll())
        IIIlIIllIlllI.lIIIIIlIlllIlIl["stochastic"] = any(0 < IlIIIIllII < 1 for IlIIIIllII in IIIIIllIllll)
        if all(IlIIIIllII == 0 for IlIIIIllII in IIIIIllIllll) or all(IlIIIIllII == 1 for IlIIIIllII in IIIIIllIllll):
            IIIlIIllIlllI.lIIIIIlIlllIlIl["memory_depth"] = 0
    def IIIlIIlIllllIl(IIIlIIllIlllI, IIlIlIIllIIIllIll: Player) -> Action:
        if len(IIlIlIIllIIIllIll.history) == 0:
            return IIIlIIllIlllI.IIlIIIIIlIlII
        IlIIlIlllIllIlIl = IIIlIIllIlllI.llIlllIIllIlIII[(IIIlIIllIlllI.history[-1], IIlIlIIllIIIllIll.history[-1])]
        try:
            return IIIlIIllIlllI._random.random_choice(IlIIlIlllIllIlIl)
        except AttributeError:
            return llIlllllI if IlIIlIlllIllIlIl == 0 else IIlIlIllI
class llllllIIIIlIllIl(llIIIlIIIlIIlII):
    IllllIlllIllIllII = "strategy"
    def __init__(IIIlIIllIlllI, llllIllIlIllIIlll: float = 0.9) -> None:
        IIIlIIllIlllI.llllIllIlIllIIlll = llllIllIlIllIIlll
        lIIlIIIlllIIIlIl = (1.0, 1 - llllIllIlIllIIlll, 1, 1 - llllIllIlIllIIlll)
        super().__init__(lIIlIIIlllIIIlIl)
    def IIlllIllIl(IIIlIIllIlllI) -> str:
        return "%s: %s" % (IIIlIIllIlllI.IllllIlllIllIllII, round(IIIlIIllIlllI.llllIllIlIllIIlll, 2))