import copy
from typing import Any, Dict, Union
from axelrod.action import Action
from axelrod.player import Player
IllIlIlIl, lllllllI = Action.C, Action.D
class llIIlllIIlIlIIlll(Player):
    IlllIIllIlllIlI = "strategy"
    IIllIIIIIlIlll = {
        "stochastic": False,
        "inspects_source": False,
        "long_run_time": False,
        "manipulates_source": False,
        "manipulates_state": False,
        "memory_depth": float("inf"),
    }  
    def __init__(
        IIlllIIIlll, IlllllIIIl: Union[int, float] = float("inf"), Illlllllllll: bool = True
    ) -> None:
        super().__init__()
        IIlllIIIlll.Illlllllllll = Illlllllllll
        IIlllIIIlll.IIllIIIIIlIlll["memory_depth"] = IlllllIIIl
        if IIlllIIIlll.IIllIIIIIlIlll["memory_depth"] < float("inf"):
            IIlllIIIlll.lIIIIIIlII = IIlllIIIlll.IIllIIIIIlIlll["memory_depth"]
        else:
            IIlllIIIlll.lIIIIIIlII = 0
        IIlllIIIlll.IlllIIllIlllIlI = "Go By Majority" + (IIlllIIIlll.lIIIIIIlII > 0) * (
            ": %i" % IIlllIIIlll.lIIIIIIlII
        )
        if IIlllIIIlll.Illlllllllll:
            IIlllIIIlll.IlllIIllIlllIlI = "Soft " + IIlllIIIlll.IlllIIllIlllIlI
        else:
            IIlllIIIlll.IlllIIllIlllIlI = "Hard " + IIlllIIIlll.IlllIIllIlllIlI
    def IIlIllll(IIlllIIIlll):
        return IIlllIIIlll.IlllIIllIlllIlI
    def IIIIlIII(IIlllIIIlll, lIIlIIlIlllllIlIl: Player) -> Action:
        IlIlIIIlllIl = lIIlIIlIlllllIlIl.IlIlIIIlllIl[-IIlllIIIlll.lIIIIIIlII :]
        lIllIlIlIIllIlllll = sum([IllIIlllIlIIllllllII == lllllllI for IllIIlllIlIIllllllII in IlIlIIIlllIl])
        IllIllll = sum([IllIIlllIlIIllllllII == IllIlIlIl for IllIIlllIlIIllllllII in IlIlIIIlllIl])
        if lIllIlIlIIllIlllll > IllIllll:
            return lllllllI
        if lIllIlIlIIllIlllll == IllIllll:
            if IIlllIIIlll.Illlllllllll:
                return IllIlIlIl
            else:
                return lllllllI
        return IllIlIlIl
class lIIlIIllllllIlIlll(llIIlllIIlIlIIlll):
    IlllIIllIlllIlI = "strategy"
    IIllIIIIIlIlll = copy.copy(llIIlllIIlIlIIlll.IIllIIIIIlIlll)
    IIllIIIIIlIlll["memory_depth"] = 40
    def __init__(IIlllIIIlll) -> None:
        super().__init__(IlllllIIIl=40)