👨‍💻 dev AXContains

development

fukurou

the supreme coder
ADMIN
Code:
from typing import Set

def contains_element(my_set: Set[int], element: int) -> bool:
    return element in my_set

# Example usage
my_set: Set[int] = {1, 2, 3, 4, 5}
print(contains_element(my_set, 3))  # Output: True
print(contains_element(my_set, 6))  # Output: False
 

fukurou

the supreme coder
ADMIN
Python:
class DiWarrior(Skill):
    def __init__(self):
        super().__init__()  # Call the parent class constructor
        self.fightSpirit: int = 6
        self.replenisher = TrgEveryNMinutes(TimeUtils.getCurrentTimeStamp(),5)
        self.evolver = AnnoyedQ(2)
        self.warmode = False
        self.attacked: set[str] = {"punch", "kick", "jab", "uppercut", "roundhouse"}
        self.wimpMoves: UniqueResponder = UniqueResponder("uncle","stop","ouwee","you are a meanie")
        # war mode:
        self.trgs: list[set[str]] = []
        self.trgs.append({"a","b","c"})
        self.trgs.append({"e","f"})
        self.trgs.append({"g","h"})
        self.strategies: list[AXStrategy] = []


    def input(self, ear, skin, eye):
        # reset spirit, reset Q
        if self.replenisher.trigger():
            if self.replenisher == 0:
                self.setSimpleAlg("fight spirit replenished")
            self.fightSpirit = 6
            self.evolver.reset()
        # attacked?: spirit?:warmode;else wimp move
        if self.attacked.__contains__(ear): # change to eye or skin when bot body available
            if self.fightSpirit > 0:
                self.warmode = True
                self.setSimpleAlg("engaging battle mode")
            else:
                self.setSimpleAlg(self.wimpMoves.getAResponse())

        # warmode:
        # if warmode:
        # if AQ evolve ref
        # loop: if [i].contains: strategy;save ref;c--;if uncle or c==0:warmode= F
 

fukurou

the supreme coder
ADMIN
Python:
class DiWarrior(Skill):
    def __init__(self):
        super().__init__()  # Call the parent class constructor
        self.fightSpirit: int = 6
        self.replenisher = TrgEveryNMinutes(TimeUtils.getCurrentTimeStamp(),5)
        self.evolver = 0  # hits taken
        self.warmode = False
        self.attacked: set[str] = {"punch", "kick", "jab", "uppercut", "roundhouse"}
        self.wimpMoves: UniqueResponder = UniqueResponder("uncle","stop","ouwee","you are a meanie")
        # war mode:
        self.trgs: list[set[str]] = []
        self.trgs.append({"crunch","def"})
        self.trgs.append({"punch", "kick", "jab", "uppercut", "roundhouse"})
        self.strategies: list[Strategy] = []
        self.strategies.append(Strategy(UniqueResponder("punch", "kick", "jab", "uppercut", "roundhouse"),2)) # offense
        self.strategies.append(Strategy(UniqueResponder("back dash", "weaving"), 2))  # deffense
        self.ref: Strategy = self.strategies[0]


    def input(self, ear, skin, eye):
        # reset spirit
        if self.replenisher.trigger():
            if self.fightSpirit == 0:
                self.setSimpleAlg("fight spirit replenished")
            self.fightSpirit = 6
            self.evolver = 0
        # attacked?
        if self.attacked.__contains__(ear): # change to eye or skin when bot body available
            if self.warmode:  # get hit? evolve strategies
                self.evolver +=1
                if self.evolver > 2:
                    self.ref.evolveStrategies()
                    self.evolver = 0
                    print("strategy evolved")
            else:
                if self.fightSpirit > 0:
                    self.warmode = True
                    self.setSimpleAlg("engaging battle mode")
                    return
                else:
                    self.setSimpleAlg(self.wimpMoves.getAResponse())
        # warmode:
        if self.warmode:
            if self.fightSpirit == 0 or ear == "uncle":
                self.setSimpleAlg("uncle")
                self.warmode = False
                return
            for i in range(len(self.trgs)):
                if self.trgs[i].__contains__(ear):
                    ref = self.strategies[i]
                    self.fightSpirit -= 1
                    self.setSimpleAlg(ref.getStrategy())
                    return

Python:
class Strategy:
    def __init__(self, allStrategies: UniqueResponder, strategiesLim: int):
        # bank of all strategies. out of this pool active strategies are pulled
        self._allStrategies: UniqueResponder = allStrategies
        self._strategiesLim = strategiesLim
        # active strategic options
        self._activeStrategy: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(strategiesLim)
        for i in range(0, self._strategiesLim):
            self._activeStrategy.insert(self._allStrategies.getAResponse())

    def evolveStrategies(self):
        for i in range(0, self._strategiesLim):
            self._activeStrategy.insert(self._allStrategies.getAResponse())

    def getStrategy(self) -> str:
        return self._activeStrategy.getRNDElement()
 

fukurou

the supreme coder
ADMIN
Python:
class DiWarrior(Skill):
    def __init__(self):
        super().__init__()  # Call the parent class constructor
        self.fightSpirit: int = 6
        self.replenisher = TrgEveryNMinutes(TimeUtils.getCurrentTimeStamp(),5)
        self.evolver = 0  # hits taken
        self.warmode = False
        self.attacked: set[str] = {"punch", "kick", "jab", "uppercut", "roundhouse"}
        self.wimpMoves: UniqueResponder = UniqueResponder("uncle","stop","ouwee","you are a meanie")
        # war mode:
        self.trgs: list[set[str]] = []
        self.trgs.append({"crunch","def"})
        self.trgs.append({"punch", "kick", "jab", "uppercut", "roundhouse"})
        self.strategies: list[Strategy] = []
        self.strategies.append(Strategy(UniqueResponder("punch", "kick", "jab", "uppercut", "roundhouse"),2)) # offense
        self.strategies.append(Strategy(UniqueResponder("back dash", "weaving"), 2))  # deffense
        self.ref: Strategy = self.strategies[0]


    def input(self, ear, skin, eye):
        # reset spirit
        if self.replenisher.trigger():
            if self.fightSpirit == 0:
                self.setVerbatimAlg(3,"fight spirit replenished")
            elif self.fightSpirit < 6:
                self.setVerbatimAlg(3,"exiting battle mode")
            self.fightSpirit = 6
            self.evolver = 0
            self.warmode = False
        # attacked?
        if self.attacked.__contains__(ear): # change to eye or skin when bot body available
            if self.warmode:  # get hit? evolve strategies
                self.evolver +=1
                if self.evolver > 2:
                    self.ref.evolveStrategies()
                    self.evolver = 0
                    # strategy evolved
            else:
                if self.fightSpirit > 0:
                    self.warmode = True
                    self.setVerbatimAlg(3,"engaging battle mode")
                    return
                else:
                    self.setSimpleAlg(self.wimpMoves.getAResponse())
        # warmode:
        if self.warmode:
            if self.fightSpirit == 0 or ear == "uncle":
                self.setVerbatimAlg(3,"uncle")
                self.warmode = False
                return
            for i in range(len(self.trgs)):
                if self.trgs[i].__contains__(ear):
                    ref = self.strategies[i]
                    self.fightSpirit -= 1
                    self.setVerbatimAlg(3,ref.getStrategy())
                    return
 
Top