import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
lIlllllllll, IIIIIIIIllIlllI = Action.C, Action.D
class IlllllIlllIll(Player):
    IIllIllIlllllll = "strategy"
    llIIIllII = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        lIIIllIIlIllII,
        lIlIIlIIl: Optional[Tuple[float, float, float, float]] = None,
        IIIlIlllllIl: Action = lIlllllllll,
    ) -> None:
        super().__init__()
        lIIIllIIlIllII.IlIIIlll = IIIlIlllllIl
        lIIIllIIlIllII.lIIlllIIllIllllIlIll(lIlIIlIIl)
    def lIIlllIIllIllllIlIll(lIIIllIIlIllII, lIlIIlIIl):
        if lIlIIlIIl is None:
            lIlIIlIIl = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        lIIIllIIlIllII.llIIIIIIlllllIllll(lIlIIlIIl)
    def llIIIIIIlllllIllll(lIIIllIIlIllII, lIlIIlIIl: Tuple[float, float, float, float]):
        if not all(0 <= llllIllIlIllIlIII <= 1 for llllIllIlIllIlIII in lIlIIlIIl):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(lIlIIlIIl))
            )
        lIIIllIIlIllII.IlIllIlIlIllIlIIlIl = dict(
            zip([(lIlllllllll, lIlllllllll), (lIlllllllll, IIIIIIIIllIlllI), (IIIIIIIIllIlllI, lIlllllllll), (IIIIIIIIllIlllI, IIIIIIIIllIlllI)], lIlIIlIIl)
        )
    def llIIIIlII(lIIIllIIlIllII):
        IlIIIlIIIll = set(lIIIllIIlIllII.IlIllIlIlIllIlIIlIl.IlIIIlIIIll())
        lIIIllIIlIllII.llIIIllII["stochastic"] = any(0 < IIIIllIlIIllIl < 1 for IIIIllIlIIllIl in IlIIIlIIIll)
        if all(IIIIllIlIIllIl == 0 for IIIIllIlIIllIl in IlIIIlIIIll) or all(IIIIllIlIIllIl == 1 for IIIIllIlIIllIl in IlIIIlIIIll):
            lIIIllIIlIllII.llIIIllII["memory_depth"] = 0
    def IllIlIIIIIl(lIIIllIIlIllII, IlllIlII: Player) -> Action:
        if len(IlllIlII.history) == 0:
            return lIIIllIIlIllII.IlIIIlll
        llllIllIlIllIlIII = lIIIllIIlIllII.IlIllIlIlIllIlIIlIl[(lIIIllIIlIllII.history[-1], IlllIlII.history[-1])]
        try:
            return lIIIllIIlIllII._random.random_choice(llllIllIlIllIlIII)
        except AttributeError:
            return IIIIIIIIllIlllI if llllIllIlIllIlIII == 0 else lIlllllllll