import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
lIIlIllll, IlIlIlIIIl = Action.C, Action.D
class IIIIIlIllIIl(Player):
    llIIlIIIIlIlllIII = "strategy"
    IlllllllllIllIIIlllI = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        IIIIllIIlllIIlIlII,
        lIIIIIIl: Optional[Tuple[float, float, float, float]] = None,
        IllIIllIII: Action = lIIlIllll,
    ) -> None:
        super().__init__()
        IIIIllIIlllIIlIlII.IlllIIIIIllllI = IllIIllIII
        IIIIllIIlllIIlIlII.IIIlIllllllllIlIIIIl(lIIIIIIl)
    def IIIlIllllllllIlIIIIl(IIIIllIIlllIIlIlII, lIIIIIIl):
        if lIIIIIIl is None:
            lIIIIIIl = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        IIIIllIIlllIIlIlII.lIIIlIlIlII(lIIIIIIl)
    def lIIIlIlIlII(IIIIllIIlllIIlIlII, lIIIIIIl: Tuple[float, float, float, float]):
        if not all(0 <= IIllIllIIlll <= 1 for IIllIllIIlll in lIIIIIIl):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(lIIIIIIl))
            )
        IIIIllIIlllIIlIlII.lllIllIlIlIllIIllI = dict(
            zip([(lIIlIllll, lIIlIllll), (lIIlIllll, IlIlIlIIIl), (IlIlIlIIIl, lIIlIllll), (IlIlIlIIIl, IlIlIlIIIl)], lIIIIIIl)
        )
    def lIIllllIIlllIIIIllll(IIIIllIIlllIIlIlII):
        lIIIlIlI = set(IIIIllIIlllIIlIlII.lllIllIlIlIllIIllI.lIIIlIlI())
        IIIIllIIlllIIlIlII.IlllllllllIllIIIlllI["stochastic"] = any(0 < lllllIIlIIIIllIIl < 1 for lllllIIlIIIIllIIl in lIIIlIlI)
        if all(lllllIIlIIIIllIIl == 0 for lllllIIlIIIIllIIl in lIIIlIlI) or all(lllllIIlIIIIllIIl == 1 for lllllIIlIIIIllIIl in lIIIlIlI):
            IIIIllIIlllIIlIlII.IlllllllllIllIIIlllI["memory_depth"] = 0
    def llllIIlIlIIllllIlI(IIIIllIIlllIIlIlII, IIIlllllIlIllIlIl: Player) -> Action:
        if len(IIIlllllIlIllIlIl.history) == 0:
            return IIIIllIIlllIIlIlII.IlllIIIIIllllI
        IIllIllIIlll = IIIIllIIlllIIlIlII.lllIllIlIlIllIIllI[(IIIIllIIlllIIlIlII.history[-1], IIIlllllIlIllIlIl.history[-1])]
        try:
            return IIIIllIIlllIIlIlII._random.random_choice(IIllIllIIlll)
        except AttributeError:
            return IlIlIlIIIl if IIllIllIIlll == 0 else lIIlIllll
class IIIllIIllllIII(IIIIIlIllIIl):
    llIIlIIIIlIlllIII = "strategy"
    IlllllllllIllIIIlllI = {
        "memory_depth": 1,  
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IIIIllIIlllIIlIlII, IllIIllIII: Action = IlIlIlIIIl) -> None:
        lIIIIIIl = (0, 1, 1, 0)
        super().__init__(lIIIIIIl)
        IIIIllIIlllIIlIlII.IlllIIIIIllllI = IllIIllIII