we need to find the entry points

owly

闇の伝説
Staff member
戦闘 コーダー
Python:
class AXNPC2(AXNPC):

    def __init__(self, replyStockLim: int, outputChance: int):
        super().__init__(replyStockLim, outputChance)
        self.annoyedQue: AnnoyedQ = AnnoyedQ(5)

    def strLearn(self, ear: str):
        # learns inputs containing strings that are repeatedly used by others
        self.annoyedQue.learn(ear)
        if self.annoyedQue.isAnnoyed(ear):
            self.responder.insert(ear)

Python:
class AXNPC:
    def __init__(self, replyStackLim: int, outputChance: int):
        self.responder: RefreshQ = RefreshQ(replyStackLim)
        self.dripper = PercentDripper()
        if 0 < outputChance < 101:
            self.dripper.setLimit(outputChance)
        self.cmdBreaker: AXCmdBreaker = AXCmdBreaker("say")

    def respond(self) -> str:
        if self.dripper.drip():
            return self.responder.getRNDElement()
        return ""

    def respondPlus(self, plus) -> str:
        if self.dripper.dripPlus(plus):
            return self.responder.getRNDElement()
        return ""

    def learn(self, ear: str) -> bool:
        # say hello there : hello there is learned
        temp: str = self.cmdBreaker.extractCmdParam(ear)
        if len(temp) == 0:
            return False
        self.responder.insert(temp)
        return True

    def strRespond(self, ear: str) -> str:
        # respond if ear contains a learned input
        if len(ear) == 0:
            return ""
        if self.dripper.drip() and self.responder.strContainsResponse(ear):
            return self.responder.getRNDElement()
        return ""

    def forceRespond(self) -> str:
        return self.responder.getRNDElement()

    def setConjuration(self, conjuration: str):
        self.cmdBreaker.conjuration = conjuration
 

fukurou

the supreme coder
ADMIN
assuming you aren't talking about onaholes...

strLearn
learn

are the 2 entry points.
I would recommend doing a ver3:
  • entry points should return a Boolean
  • without the unrelated methods
  • a return for the RefreshQ list
  • a load method
r:RefreshQ = RefreshQ(5)
r.insert("1")
r.insert("2")
r.insert("3")
r.insert("1")
print(r.queue)
n:list[str]
n= r.queue
print(n)
r.queue = n[1:]
print(r.queue)
 

owly

闇の伝説
Staff member
戦闘 コーダー
so the alg would be:
strRespond->t
if t:
say t; return;
learn1?||learn2?->save

also strLearn should exclude the canjuration
 

owly

闇の伝説
Staff member
戦闘 コーダー
if not npc.learn(ear):
# str learn
npc.strLearn(ear)
 

fukurou

the supreme coder
ADMIN
wait I think I found it:
Python:
        if not npc.learn(ear):
            # str learn
            npc.strLearn(ear)

let's try:
Code:
        if not npc.learn(ear):
            # str learn
            if not npc.strLearn(ear):
                return
        save
npc.strLearn(ear) should return a boolean
the load will be in the c'tor
 

fukurou

the supreme coder
ADMIN
Python:
class DiBlabberV3(DiSkillV2):
    def __init__(self, memory_size: int = 9, reply_chance: int = 90):
        super().__init__()
        self.npc: AXNPC2 = AXNPC2(memory_size, reply_chance)
        self._temp_str: str = ""
        self.splitter: AXStringSplit = AXStringSplit()
        self._initialized: bool = False

    def input(self, ear: str, skin: str, eye: str):
        if len(ear) == 0:
            return
        if not self._initialized:
            self.npc.responder.queue = self.splitter.split(self.getKokoro().grimoireMemento.simpleLoad("blabberv3"))
            self._initialized = True
        self._temp_str = self.npc.strRespond(ear)
        if len(self._temp_str) > 0:
            self.setSimpleAlg(Eliza.PhraseMatcher.reflect(self.npc.forceRespond()))
        if not self.npc.learn(ear):
            # str learn
            if not self.npc.strLearn(ear):
                return
        self.getKokoro().grimoireMemento.simpleSave("blabberv3", self.splitter.stringBuilder(self.npc.responder.queue))
 
Top