import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
IIlIllIIlllIIIIllI, IlIIlllIlllIlIllllll = Action.C, Action.D
class IllIlllIlIIlIIllII(Player):
    lIlIIlIIl = "strategy"
    lIIllIlIllIlIIIIlII = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        IlIlllIIIlIIIIlIllI,
        lIIllIlllIllII: Optional[Tuple[float, float, float, float]] = None,
        IlIllIllIIll: Action = IIlIllIIlllIIIIllI,
    ) -> None:
        super().__init__()
        IlIlllIIIlIIIIlIllI.lIllIIllIllIIllIlIlI = IlIllIllIIll
        IlIlllIIIlIIIIlIllI.IIIlIIIIlIlllIIl(lIIllIlllIllII)
    def IIIlIIIIlIlllIIl(IlIlllIIIlIIIIlIllI, lIIllIlllIllII):
        if lIIllIlllIllII is None:
            lIIllIlllIllII = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        IlIlllIIIlIIIIlIllI.llIIIllllIl(lIIllIlllIllII)
    def llIIIllllIl(IlIlllIIIlIIIIlIllI, lIIllIlllIllII: Tuple[float, float, float, float]):
        if not all(0 <= IlllllIIlIll <= 1 for IlllllIIlIll in lIIllIlllIllII):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(lIIllIlllIllII))
            )
        IlIlllIIIlIIIIlIllI.llIlllIIllIIIIIIIl = dict(
            zip([(IIlIllIIlllIIIIllI, IIlIllIIlllIIIIllI), (IIlIllIIlllIIIIllI, IlIIlllIlllIlIllllll), (IlIIlllIlllIlIllllll, IIlIllIIlllIIIIllI), (IlIIlllIlllIlIllllll, IlIIlllIlllIlIllllll)], lIIllIlllIllII)
        )
    def IIlIllIlIlI(IlIlllIIIlIIIIlIllI):
        lIIIIlIIIlIlIl = set(IlIlllIIIlIIIIlIllI.llIlllIIllIIIIIIIl.lIIIIlIIIlIlIl())
        IlIlllIIIlIIIIlIllI.lIIllIlIllIlIIIIlII["stochastic"] = any(0 < llIIllllllllIl < 1 for llIIllllllllIl in lIIIIlIIIlIlIl)
        if all(llIIllllllllIl == 0 for llIIllllllllIl in lIIIIlIIIlIlIl) or all(llIIllllllllIl == 1 for llIIllllllllIl in lIIIIlIIIlIlIl):
            IlIlllIIIlIIIIlIllI.lIIllIlIllIlIIIIlII["memory_depth"] = 0
    def lllIlIII(IlIlllIIIlIIIIlIllI, IIllllIll: Player) -> Action:
        if len(IIllllIll.history) == 0:
            return IlIlllIIIlIIIIlIllI.lIllIIllIllIIllIlIlI
        IlllllIIlIll = IlIlllIIIlIIIIlIllI.llIlllIIllIIIIIIIl[(IlIlllIIIlIIIIlIllI.history[-1], IIllllIll.history[-1])]
        try:
            return IlIlllIIIlIIIIlIllI._random.random_choice(IlllllIIlIll)
        except AttributeError:
            return IlIIlllIlllIlIllllll if IlllllIIlIll == 0 else IIlIllIIlllIIIIllI
class lIllllIlIlllllI(IllIlllIlIIlIIllII):
    lIlIIlIIl = "strategy"
    def __init__(IlIlllIIIlIIIIlIllI) -> None:
        lIIllIlllIllII = (0.935, 0.229, 0.266, 0.42)
        super().__init__(lIIllIlllIllII)
        IlIlllIIIlIIIIlIllI.llIIIllllIl(lIIllIlllIllII)