import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
lIIIlIIlllllllIIIl, IlIIIlIlI = Action.C, Action.D
class lIlllllIlllllIlIIIl(Player):
    IIllllIlI = "strategy"
    IlIIIllIlIll = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        IlllllIllIllI,
        IlllIlIlIlI: Optional[Tuple[float, float, float, float]] = None,
        lIlIIllIIIIIIllIlllI: Action = lIIIlIIlllllllIIIl,
    ) -> None:
        super().__init__()
        IlllllIllIllI.IllIIIIlllI = lIlIIllIIIIIIllIlllI
        IlllllIllIllI.IIllIllllIIllIIllIl(IlllIlIlIlI)
    def IIllIllllIIllIIllIl(IlllllIllIllI, IlllIlIlIlI):
        if IlllIlIlIlI is None:
            IlllIlIlIlI = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        IlllllIllIllI.lIIlIIlIIllIllIIlll(IlllIlIlIlI)
    def lIIlIIlIIllIllIIlll(IlllllIllIllI, IlllIlIlIlI: Tuple[float, float, float, float]):
        if not all(0 <= IIIlIIIllllI <= 1 for IIIlIIIllllI in IlllIlIlIlI):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(IlllIlIlIlI))
            )
        IlllllIllIllI.lIIlIIllllllllIl = dict(
            zip([(lIIIlIIlllllllIIIl, lIIIlIIlllllllIIIl), (lIIIlIIlllllllIIIl, IlIIIlIlI), (IlIIIlIlI, lIIIlIIlllllllIIIl), (IlIIIlIlI, IlIIIlIlI)], IlllIlIlIlI)
        )
    def llIlIlIIIIlIlIIII(IlllllIllIllI):
        lIIIIllIIIIlII = set(IlllllIllIllI.lIIlIIllllllllIl.lIIIIllIIIIlII())
        IlllllIllIllI.IlIIIllIlIll["stochastic"] = any(0 < lIlIlIllIIIIllllII < 1 for lIlIlIllIIIIllllII in lIIIIllIIIIlII)
        if all(lIlIlIllIIIIllllII == 0 for lIlIlIllIIIIllllII in lIIIIllIIIIlII) or all(lIlIlIllIIIIllllII == 1 for lIlIlIllIIIIllllII in lIIIIllIIIIlII):
            IlllllIllIllI.IlIIIllIlIll["memory_depth"] = 0
    def IlIIIlIIIlll(IlllllIllIllI, lIllllIll: Player) -> Action:
        if len(lIllllIll.history) == 0:
            return IlllllIllIllI.IllIIIIlllI
        IIIlIIIllllI = IlllllIllIllI.lIIlIIllllllllIl[(IlllllIllIllI.history[-1], lIllllIll.history[-1])]
        try:
            return IlllllIllIllI._random.random_choice(IIIlIIIllllI)
        except AttributeError:
            return IlIIIlIlI if IIIlIIIllllI == 0 else lIIIlIIlllllllIIIl
class lIllIIIIIII(lIlllllIlllllIlIIIl):
    IIllllIlI = "strategy"
    def __init__(IlllllIllIllI) -> None:
        IlllIlIlIlI = (1, 0, 1, 2 / 3)
        super().__init__(IlllIlIlIlI)
        IlllllIllIllI.lIIlIIlIIllIllIIlll(IlllIlIlIlI)