import warnings
from typing import Optional, Tuple
from axelrod.action import Action
from axelrod.player import Player
lIlIllIl, IllIlIIIlll = Action.C, Action.D
class lIlIIIIIlllII(Player):
    lIlIIlIIllllIlIl = "strategy"
    lIlIllIIlIllIl = {
        "memory_depth": 1,  
        "stochastic": True,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(
        lIIIlIlIllIlIllIlll,
        IIlIlIllllllIIlIll: Optional[Tuple[float, float, float, float]] = None,
        lIllllllIllIlllllIl: Action = lIlIllIl,
    ) -> None:
        super().__init__()
        lIIIlIlIllIlIllIlll.llIllIIIllIllIlIlI = lIllllllIllIlllllIl
        lIIIlIlIllIlIllIlll.IIIIIlllllI(IIlIlIllllllIIlIll)
    def IIIIIlllllI(lIIIlIlIllIlIllIlll, IIlIlIllllllIIlIll):
        if IIlIlIllllllIIlIll is None:
            IIlIlIllllllIIlIll = (1, 0, 0, 1)
            warnings.warn("Memory one player is set to default (1, 0, 0, 1).")
        lIIIlIlIllIlIllIlll.lIIIIllIIl(IIlIlIllllllIIlIll)
    def lIIIIllIIl(lIIIlIlIllIlIllIlll, IIlIlIllllllIIlIll: Tuple[float, float, float, float]):
        if not all(0 <= lIIlIlIIIl <= 1 for lIIlIlIIIl in IIlIlIllllllIIlIll):
            raise ValueError(
                "An element in the probability vector, {}, is not "
                "between 0 and 1.".format(str(IIlIlIllllllIIlIll))
            )
        lIIIlIlIllIlIllIlll.llIlIIIlIllIIllIIIIl = dict(
            zip([(lIlIllIl, lIlIllIl), (lIlIllIl, IllIlIIIlll), (IllIlIIIlll, lIlIllIl), (IllIlIIIlll, IllIlIIIlll)], IIlIlIllllllIIlIll)
        )
    def IIIllIIIlIlIlllIllll(lIIIlIlIllIlIllIlll):
        llIIllllI = set(lIIIlIlIllIlIllIlll.llIlIIIlIllIIllIIIIl.llIIllllI())
        lIIIlIlIllIlIllIlll.lIlIllIIlIllIl["stochastic"] = any(0 < IIllIIIIl < 1 for IIllIIIIl in llIIllllI)
        if all(IIllIIIIl == 0 for IIllIIIIl in llIIllllI) or all(IIllIIIIl == 1 for IIllIIIIl in llIIllllI):
            lIIIlIlIllIlIllIlll.lIlIllIIlIllIl["memory_depth"] = 0
    def lIlIllIIllIlIllIIl(lIIIlIlIllIlIllIlll, lllIlIIIlIllIIIlIl: Player) -> Action:
        if len(lllIlIIIlIllIIIlIl.history) == 0:
            return lIIIlIlIllIlIllIlll.llIllIIIllIllIlIlI
        lIIlIlIIIl = lIIIlIlIllIlIllIlll.llIlIIIlIllIIllIIIIl[(lIIIlIlIllIlIllIlll.history[-1], lllIlIIIlIllIIIlIl.history[-1])]
        try:
            return lIIIlIlIllIlIllIlll._random.random_choice(lIIlIlIIIl)
        except AttributeError:
            return IllIlIIIlll if lIIlIlIIIl == 0 else lIlIllIl
class lIIIlIIllllIlIl(lIlIIIIIlllII):
    lIlIIlIIllllIlIl = "strategy"
    def __init__(lIIIlIlIllIlIllIlll, IIlIlIIll: float = 0.05) -> None:
        lIIIlIlIllIlIllIlll.IIlIlIIll = IIlIlIIll
        IIlIlIllllllIIlIll = (1.0 - IIlIlIIll, IIlIlIIll, IIlIlIIll, 1.0 - IIlIlIIll)
        super().__init__(IIlIlIllllllIIlIll)
        lIIIlIlIllIlIllIlll.lIIIIllIIl(IIlIlIllllllIIlIll)