🐍 python python time

python

fukurou

the supreme coder
ADMIN
Python:
class UniqueItemSizeLimitedPriorityQueue(UniqueItemsPriorityQue):
    # items in the queue are unique and do not repeat
    # the size of the queue is limited
    # this cls can also be used to detect repeated elements (nagging or reruns)
    def __init__(self, limit: int):
        super().__init__()
        self._limit = limit

    def getLimit(self) -> int:
        return self._limit

    def setLimit(self, limit: int):
        self._limit = limit

    # override
    def insert(self, data):
        if super().size() == self._limit:
            super().poll()
        super().insert(data)

    # override
    def poll(self):
        # returns string
        temp = super().poll()
        if temp is None:
            return ""
        return temp

    # override
    def getRNDElement(self):
        temp = super().getRNDElement()
        if temp is None:
            return ""
        return temp

    def getAsList(self) -> list[str]:
        return self.queue
 

owly

闇の伝説
Staff member
戦闘 コーダー

Java:
public class TODOListManager {
    /* manages to do tasks.
    q1 tasks are mentioned once, and forgotten
    backup tasks are the memory of recently mentioned tasks
    * */
    private UniqueItemSizeLimitedPriorityQueue q1 = new UniqueItemSizeLimitedPriorityQueue();
    private UniqueItemSizeLimitedPriorityQueue backup = new UniqueItemSizeLimitedPriorityQueue();

    public TODOListManager(int todoLim) {
        q1.setLimit(todoLim);
        backup.setLimit(todoLim);
    }

    public void addTask(String e1){
        q1.add(e1);
    }
    public String getTask(){
        String temp = q1.poll();
        if(!temp.isEmpty()){backup.add(temp);}
        return temp;
    }
    public String getOldTask(){
        // task graveyard (tasks you've tackled already)
        return backup.getRNDElement();
    }
    public void clearAllTasks(){
        q1.clear();
        backup.clear();
    }
    public void clearTask(String task){
        q1.removeItem(task);
        backup.removeItem(task);
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class TODOListManager:
    '''manages to do tasks.
    q1 tasks are mentioned once, and forgotten
    backup tasks are the memory of recently mentioned tasks'''

    def __init__(self, todoLim: int):
        self._q1: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(todoLim)
        self._backup: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(todoLim)

    def addTask(self, e1: str):
        self._q1.insert(e1)

    def getTask(self) -> str:
        temp: str = self._q1.poll()
        if not temp == "":
            self._backup.insert(temp)
        return temp

    def getOldTask(self):
        # task graveyard (tasks you've tackled already)
        return self._backup.getRNDElement()

    def clearAllTasks(self):
        self._q1.clear()
        self._backup.clear()

    def clearTask(self, task: str):
        self._q1.removeItem(task)
        self._backup.removeItem(task)
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class AXNeuroSama {
    private Responder nyaa = new Responder(" heart", " heart", " wink", " heart heart heart");
    private DrawRnd rnd = new DrawRnd();
    private int rate;

    public AXNeuroSama(int rate) {
        // the higher the rate the less likely to decorate outputs
        this.rate = rate;
    }

    public String decorate(String output){
        if (output.isEmpty()){
            return output;
        }
        if(rnd.getSimpleRNDNum(rate) == 0){
            return output + nyaa.getAResponse();
        }
        return output;
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class AXNeuroSama:
    def __init__(self, rate: int):
        # the higher the rate the less likely to decorate outputs
        self._rate: int = rate
        self._nyaa: Responder = Responder(" heart", " heart", " wink", " heart heart heart")
        self._rnd: DrawRnd = DrawRnd()

    def decorate(self, output: str):
        if output == "":
            return output
        if self._rnd.getSimpleRNDNum(self._rate) == 0:
            return output + self._nyaa.getAResponse()
        return output

class glitch fixed:

Python:
class DrawRnd:
    # draw a random element, than take said element out
    def __init__(self, *values: str):
        self.converter: LGTypeConverter = LGTypeConverter()
        self.strings: LGFIFO = LGFIFO()
        self._stringsSource: list[str] = []
        for i in range(0, len(values)):
            self.strings.insert(values[i])
            self._stringsSource.append(values[i])

    def drawAndRemove(self) -> str:
        temp: str = self.strings.getRNDElement()
        self.strings.removeItem(temp)
        return temp

    def drawAsIntegerAndRemove(self) -> int:
        temp: str = self.strings.getRNDElement()
        if temp is None:
            return 0
        self.strings.removeItem(temp)
        return self.converter.convertToInt(temp)

    def getSimpleRNDNum(self, lim:int) -> int:
        return random.randint(0, lim)

    def reset(self):
        self.strings.clear()
        for t in self._stringsSource:
            self.strings.insert(t)
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class AXLHousing {
    public String decorate(String str1){
        // override me
        return "";
    }
}

 

fukurou

the supreme coder
ADMIN
Java:
public class AXLNeuroSama extends AXLHousing{
    private AXNeuroSama nyaa = new AXNeuroSama(3);

    @Override
    public String decorate(String str1) {
        return this.nyaa.decorate(str1);
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class AXLHousing:
    def decorate(self, str1: str) -> str:
        # override me
        return ""


class AXLNeuroSama(AXLHousing):
    def __init__(self):
        super().__init__()
        self._nyaa: AXNeuroSama = AXNeuroSama(3)

    def decorate(self, str1: str) -> str:
        return self._nyaa.decorate(str1)
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class AXLHub {
    // hubs many reply decorators, language translators, encriptors and other string modifiers
    // decorate(str) to decorate string using the active string decorator
    private Cycler cycler;
    private DrawRnd drawRnd = new DrawRnd();
    private int size = 0;
    private ArrayList<AXLHousing> nyaa = new ArrayList<AXLHousing>();
    private int activeNyaa = 0;
    public AXLHub(AXLHousing...nyaa) {
        for (AXLHousing temp : nyaa)
        {
            this.nyaa.add(temp);
        }
        size = this.nyaa.size();
        cycler = new Cycler(size -1);
        cycler.setToZero();
    }
    public String decorate(String str1){
        return nyaa.get(activeNyaa).decorate(str1);
    }
    public void cycleDecoration(){
        activeNyaa = cycler.cycleCount();
    }
    public void randomizeDecoration(){
        activeNyaa = drawRnd.getSimpleRNDNum(size);
    }
    public void modeDecoration(int mode){
        if(mode < -1){return;}
        if(mode >= nyaa.size()){return;}
        activeNyaa = mode;
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class AXLHub:
    # hubs many reply decorators, language translators, encriptors and other string modifiers
    # decorate(str) to decorate string using the active string decorator
    def __init__(self, *nyaa: AXLHousing):
        self._nyaa: list[AXLHousing] = []
        size: int = len(nyaa)
        for i in range(0, size):
            self._nyaa.append(nyaa[i])
        self._cycler: Cycler = Cycler(size - 1)
        self._cycler.setToZero()
        self._drawRnd: DrawRnd = DrawRnd()
        self._activeNyaa = 0

    def decorate(self, str1: str) -> str:
        return self._nyaa[self._activeNyaa].decorate(str1)

    def cycleDecoration(self):
        self._activeNyaa = self._cycler.cycleCount()

    def randomizeDecoration(self):
        self._activeNyaa = self._drawRnd.getSimpleRNDNum(len(self._nyaa))

    def modeDecoration(self, mode: int):
        if mode < -1 or mode >= len(self._nyaa):
            return
        self._activeNyaa = mode
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class OutputDripper {
    // drips true once every limit times
    // shushes the waifubot enough time to hear a reply from user
    private int cycler = 0;
    private int limit; // set to 1 for on off effect

    public OutputDripper(int limit) {
        super();
        this.limit = limit;
        cycler = limit;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }
    public Boolean drip() {
        cycler--;
        if (cycler < 0) {
            cycler = limit;
        }
        return cycler == 0;
    }

    public void reset() {
        cycler = limit;
    }
    public void setToZero(){cycler = 0;}
    public void sync(int n){
        if((n<-1)||(n>limit)){
            return;
        }
        cycler = n;
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class OutputDripper(Cycler):
    # drips true once every limit times
    # shushes the waifubot enough time to hear a reply from user
    def __init__(self, limit: int):
        # set limit to 1 for on off effect
        super().__init__(limit)

    def drip(self) -> bool:
        return self.cycleCount() == 0
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class AXLearnability {
    private Boolean algSent = false;
    // problems that may result because of the last deployed algorithm:
    public UniqueItemSizeLimitedPriorityQueue defcons = new UniqueItemSizeLimitedPriorityQueue();// default size = 5
    // major chaotic problems that may result because of the last deployed algorithm:
    public UniqueItemSizeLimitedPriorityQueue defcon5 = new UniqueItemSizeLimitedPriorityQueue();
    // goals the last deployed algorithm aims to achieve:
    public UniqueItemSizeLimitedPriorityQueue goals = new UniqueItemSizeLimitedPriorityQueue();
    // how many failures / problems till the algorithm needs to mutate (change)
    public TrgTolerance trgTolerance;

    public AXLearnability(int tolerance) {
        this.trgTolerance = new TrgTolerance(tolerance);
        trgTolerance.reset();
    }
    public void pendAlg(){
        // an algorithm has been deployed
        // call this method when an algorithm is deployed (in a DiSkillV2 object)
        algSent = true;
        trgTolerance.trigger();
    }
    public void pendAlgWithoutConfirmation(){
        // an algorithm has been deployed
        algSent = true;
        //no need to await for a thank you or check for goal manifestation :
        // trgTolerance.trigger();
        // using this method instead of the default "pendAlg" is the same as
        // giving importance to the stick and not the carrot when learning
        // this method is mosly fitting work place situations
    }
    public Boolean mutateAlg(String input){
        // recommendation to mutate the algorithm ? true/ false
        if (!algSent) {return false;} // no alg sent=> no reason to mutate
        if (goals.contains(input)){trgTolerance.reset();algSent = false;return false;}
        // goal manifested the sent algorithm is good => no need to mutate the alg
        if (defcon5.contains(input)) {trgTolerance.reset();algSent = false; return true;}
        // ^ something bad happend probably because of the sent alg
        // recommend alg mutation
        if (defcons.contains(input)){algSent = false;
            Boolean mutate= !trgTolerance.trigger();
            if(mutate){
                trgTolerance.reset();
            }
            return mutate;}
        // ^ negative result, mutate the alg if this occures too much
        return false;
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class AXLearnability:

    def __init__(self, tolerance: int):
        self._algSent = False
        # problems that may result because of the last deployed algorithm:
        self.defcons: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(5)
        # major chaotic problems that may result because of the last deployed algorithm:
        self.defcon5: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(5)
        # goals the last deployed algorithm aims to achieve:
        self.goals: UniqueItemSizeLimitedPriorityQueue = UniqueItemSizeLimitedPriorityQueue(5)
        # how many failures / problems till the algorithm needs to mutate (change):
        self.trgTolerance: TrgTolerance = TrgTolerance(tolerance)

    def pendAlg(self):
        """// an algorithm has been deployed
        // call this method when an algorithm is deployed (in a DiSkillV2 object)"""
        self._algSent = True
        self.trgTolerance.trigger()

    def pendAlgWithoutConfirmation(self):
        # an algorithm has been deployed
        self._algSent = True
        '''//no need to await for a thank you or check for goal manifestation :
        // trgTolerance.trigger();
        // using this method instead of the default "pendAlg" is the same as
        // giving importance to the stick and not the carrot when learning
        // this method is mosly fitting work place situations'''

    def mutateAlg(self, input: str) -> bool:
        # recommendation to mutate the algorithm ? true/ false
        if not self._algSent:
            return False  # no alg sent=> no reason to mutate
        if self.goals.contains(input):
            self.trgTolerance.reset()
            self._algSent = False
            return False
        # goal manifested the sent algorithm is good => no need to mutate the alg
        if self.defcon5.contains(input):
            self.trgTolerance.reset()
            self._algSent = False
            return True
        '''// ^ something bad happend probably because of the sent alg
        // recommend alg mutation'''
        if self.defcons.contains(input):
            self._algSent = False
            mutate:bool = not self.trgTolerance.trigger()
            if mutate :
                self.trgTolerance.reset()
            return mutate
        # ^ negative result, mutate the alg if this occures too much
        return False

 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class TrgTolerance extends TrGEV3{
    // this boolean gate will return true till depletion or reset()
    private int repeats = 0;
    private int maxrepeats; //2 recomended
    public TrgTolerance(int maxrepeats) {
        this.maxrepeats = maxrepeats;
    }

    public void setMaxrepeats(int maxrepeats) {
        this.maxrepeats = maxrepeats;
        reset();
    }

    @Override
    public void reset() {
        // refill trigger
        repeats = maxrepeats;
    }

    @Override
    public Boolean trigger() {
        // will return true till depletion or reset()
        repeats--;
        if (repeats > 0) {
            return true;
        }
        return false;
    }
    public void disable(){
        repeats = 0;
    }
}
 

fukurou

the supreme coder
ADMIN
Python:
class TrgTolerance(TrGEV3):
    # this boolean gate will return true till depletion or reset()
    def __init__(self, maxrepeats: int):
        self._maxrepeats: int = maxrepeats
        self._repeates: int = 0
        
    def setMaxRepeats(self,maxRepeats:int):
        self._maxrepeats = maxRepeats
        self.reset()

    def reset(self):
        # refill trigger
        self._repeates = self._maxrepeats

    def trigger(self) -> bool:
        # will return true till depletion or reset()
        self._repeates -= 1
        if self._repeates > 0:
            return True
        return False

    def disable(self):
        self._repeates = 0
 

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public class InputFilter {
    // filter out non-relevant input
    // or filter in relevant data
    public String filter(String ear, String skin, String eye){
        // override me
        return "";
    }
    public AXKeyValuePair filter(String ear){
        // override me : key = context/category, value: param
        return new AXKeyValuePair();
    }
}
 
Top