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
llllllllIl, lllllIIIIlIIlIIIllII = Action.C, Action.D
class llIIllllIlll(Player):
    lIlIIIIlIIlI = "strategy"
    llIIllIlllIlIIIlIIll = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(llllIIlIl, IllIIIll: float = 0.05) -> None:
        super().__init__()
        llllIIlIl.IllIIIll = IllIIIll
        llllIIlIl.lIIlIllIIlIIllIIIll = False
    def lIIIlIIlIllIIlIl(llllIIlIl, IIIIllIllIIIl: Player) -> Action:
        IIllIIllIIl = len(llllIIlIl.history) + 1
        if IIllIIllIIl < 5:
            return llllllllIl
        elif IIllIIllIIl < 15:
            return IIIIllIllIIIl.history[-1]
        if IIllIIllIIl % 15 == 0:
            lIllIlllIIlIllIlII = chisquare(
                [IIIIllIllIIIl.cooperations, IIIIllIllIIIl.defections]
            ).pvalue
            llllIIlIl.lIIlIllIIlIIllIIIll = lIllIlllIIlIllIlII >= llllIIlIl.IllIIIll
        if llllIIlIl.lIIlIllIIlIIllIIIll:
            return lllllIIIIlIIlIIIllII
        else:  
            return IIIIllIllIIIl.history[-1]