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
IlIllIlIIllIIlIIl, IlIllllllIIll = Action.C, Action.D
class IIllIlIIII(Player):
    lIlIIIlIllI = "strategy"
    lIlllIlllllIlIIllI = {
        "memory_depth": float("inf"),
        "stochastic": False,
        "long_run_time": False,
        "inspects_source": False,
        "manipulates_source": False,
        "manipulates_state": False,
    }
    def __init__(IIIllIIll) -> None:
        super().__init__()
        IIIllIIll.lIlIIlIIlIlI = 0
        IIIllIIll.lIIIlIlIllIIIlIll = 0
    def IIlIlIIIlIIllllIIIlI(IIIllIIll, IlIlllIllIlIlIllllI: Player) -> Action:
        IIlIIlIlIIIII = len(IIIllIIll.history) + 1
        if IIlIIlIlIIIII == 1:
            return IlIllllllIIll
        if IIlIIlIlIIIII == 2:
            if IlIlllIllIlIlIllllI.history[-1] == IlIllIlIIllIIlIIl:
                IIIllIIll.lIlIIlIIlIlI += 1
            return IlIllllllIIll
        if IIIllIIll.history[-2] == IlIllIlIIllIIlIIl and IlIlllIllIlIlIllllI.history[-1] == IlIllIlIIllIIlIIl:
            IIIllIIll.lIlIIlIIlIlI += 1
        if IIIllIIll.history[-2] == IlIllllllIIll and IlIlllIllIlIlIllllI.history[-1] == IlIllIlIIllIIlIIl:
            IIIllIIll.lIIIlIlIllIIIlIll += 1
        IlIlIIlIlIIlllIII = IIIllIIll.lIlIIlIIlIlI / (
            IIIllIIll.cooperations + 1
        )
        IIllIllI = IIIllIIll.lIIIlIlIllIIIlIll / max(
            IIIllIIll.defections, 2
        )
        IIIlIIIlII, IIIIIlllIIIIIlllI, IlIIlIlIlIlI, IlllllII = IIIllIIll.match_attributes["game"].RPST()
        lllIllIIlIlI = IlIlIIlIlIIlllIII * IIIlIIIlII + (1 - IlIlIIlIlIIlllIII) * IlIIlIlIlIlI
        IIIIlIlIllllIlIIllI = IIllIllI * IlllllII + (1 - IIllIllI) * IIIIIlllIIIIIlllI
        if lllIllIIlIlI > IIIIlIlIllllIlIIllI:
            return IlIllIlIIllIIlIIl
        if lllIllIIlIlI < IIIIlIlIllllIlIIllI:
            return IlIllllllIIll
        return IIIllIIll.history[-1].flip()