from typing import Dict, List, Optional, Tuple
from scipy.stats import chisquare
from axelrod.action import Action
from axelrod.player import Player
from axelrod.strategy_transformers import FinalTransformer
from .memoryone import MemoryOnePlayer
lIIlIIlIIIllll, IlIIllllIlllIllIIIII = Action.C, Action.D
class lIIlIlIlllI(Player):
    IlIIIIllIllIlll = "strategy"
    lllllllIIll = {
        "memory_depth": 3,
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IIlIIIIlIIIIIIl) -> None:
        IIlIIIIlIIIIIIl.IllIllllIllIIII = [
            1,
            6,
            7,
            17,
            22,
            23,
            26,
            29,
            30,
            31,
            33,
            38,
            39,
            45,
            49,
            54,
            55,
            58,
            61,
        ]
        IIlIIIIlIIIIIIl.lIlIIlIII = {(lIIlIIlIIIllll, lIIlIIlIIIllll): 0, (lIIlIIlIIIllll, IlIIllllIlllIllIIIII): 2, (IlIIllllIlllIllIIIII, lIIlIIlIIIllll): 1, (IlIIllllIlllIllIIIII, IlIIllllIlllIllIIIII): 3}
        super().__init__()
    @staticmethod
    def llllllllIIlIlI(
        lIIlllllIIIIIlIl: List[Action],
        llllIIIllllIlII: List[Action],
        lIlIIlIII: Dict[Tuple[Action, Action], int],
    ) -> int:
        lIlllIlI = 0
        for lIlIllIIlIIllIllll, IlIIIIIIIllIIll in [(-1, 16), (-2, 4), (-3, 1)]:
            IIIIlIlIlIIIlIllIlII = (lIIlllllIIIIIlIl[lIlIllIIlIIllIllll], llllIIIllllIlII[lIlIllIIlIIllIllll])
            lIlllIlI += IlIIIIIIIllIIll * lIlIIlIII[IIIIlIlIlIIIlIllIlII]
        return lIlllIlI
    def lllIIlIIIlIlIIIlllll(IIlIIIIlIIIIIIl, lllllllIlIll: Player) -> Action:
        if len(IIlIIIIlIIIIIIl.history) == 0:
            return lIIlIIlIIIllll
        if len(IIlIIIIlIIIIIIl.history) == 1:
            return IlIIllllIlllIllIIIII if lllllllIlIll.history[-1] == IlIIllllIlllIllIIIII else lIIlIIlIIIllll
        if len(IIlIIIIlIIIIIIl.history) == 2:
            if lllllllIlIll.history[0:2] == [IlIIllllIlllIllIIIII, lIIlIIlIIIllll]:
                return IlIIllllIlllIllIIIII
            else:
                return IlIIllllIlllIllIIIII if lllllllIlIll.history[-1] == IlIIllllIlllIllIIIII else lIIlIIlIIIllll
        llllIIllIllIlIlI = IIlIIIIlIIIIIIl.llllllllIIlIlI(
            IIlIIIIlIIIIIIl.history[-3:], lllllllIlIll.history[-3:], IIlIIIIlIIIIIIl.lIlIIlIII
        )
        if llllIIllIllIlIlI in IIlIIIIlIIIIIIl.IllIllllIllIIII:
            return IlIIllllIlllIllIIIII
        return lIIlIIlIIIllll