triumph of the will

fukurou

the supreme coder
ADMIN
proper test procedure :

Python:
class DiHelloWorld(DiSkillV2):
    def __init__(self, kokoro: Kokoro):
        DiSkillV2.__init__(self, kokoro)

    # Override
    def input(self, ear: str, skin: str, eye: str):
        if ear == "hello":
            self._outAlg = self._diSkillUtils.simpleVerbatimAlgorithm("test", "hello world")


class Personality1(Personality):
    # Override
    def __init__(self, *absDictionaryDB: AbsDictionaryDB):
        super().__init__(absDictionaryDB)
        super().getdClassesLv1().append(DiHelloWorld(self.getKokoro()))


if __name__ == "__main__":
    test_personality: Personality1 = Personality1()
    chii: ChobitV2 = ChobitV2(test_personality)
    result = chii.think("hello", "", "")
    print(result)

notice adding a skill is just 1 line of code :
super().getdClassesLv1().append(DiHelloWorld(self.getKokoro()))

that is the livingrimoire design pattern
 

fukurou

the supreme coder
ADMIN
Python:
''' CHOBITSV2 CLASS '''


class ChobitV2(Thinkable):

    def __init__(self, personality: Personality):
        super().__init__()
        self.emot: str = ""  # emotion
        self.dClassesLv1: list[DiSkillV2] = personality.getdClassesLv1()
        self.dClassesLv2: list[DiSkillV2] = personality.getdClassesLv2()  # can engage with friends and work related
        self.dClassesLv3: list[DiSkillV2] = personality.getdClassesLv3()  # can engage only by user
        self.dClassesAuto: list[DiSkillV2] = []  # automatically added and engaged by time
        # algorithms fusion (polymarization)
        self.AlgDurations: dict[str, int] = personality.getAlgDurations()
        self.fusion: Fusion = personality.getFusion()
        # region essential DClasses
        self.permission: Permission = personality.getPermission()
        self.dPermitter: DPermitter = personality.getdPermitter()
        # endregion
        self.noiron: Neuron = Neuron()
        # added :
        self.kokoro: Kokoro = personality.getKokoro()  # soul
        self.lastOutput: str = ""
        # standBy phase 260320
        self.timeGate: ZeroTimeGate = ZeroTimeGate(5)
        self.formAutoClassesList()

    def loadPersonality(self, personality: Personality):
        self.AlgDurations = personality.getAlgDurations()
        self.fusion = personality.getFusion()
        self.kokoro = personality.getKokoro()
        self.permission = personality.getPermission()
        self.dPermitter = personality.getdPermitter()
        self.noiron = Neuron()
        self.dClassesLv1 = personality.getdClassesLv1()
        self.dClassesLv2 = personality.getdClassesLv2()
        self.dClassesLv3 = personality.getdClassesLv3()
        self.dClassesAuto = []
        self.formAutoClassesList()

    def formAutoClassesList(self):
        # adds automatic skills so they can be engaged by time
        for dCls in self.dClassesLv2:
            if (dCls.auto()):
                self.dClassesAuto.append(dCls)
        for dCls in self.dClassesLv3:
            if (dCls.auto()):
                self.dClassesAuto.append(dCls)

    def doIt(self, ear: str, skin: str, eye: str) -> str:
        ear = self.translateIn(ear)
        for dCls in self.dClassesAuto:
            self.inOut(dCls, "", skin, eye)
        for dCls in self.dClassesLv1:
            self.inOut(dCls, ear, skin, eye)
        if (self.dPermitter.getPermissionLevel() > 0):
            # works with friends
            for dCls in self.dClassesLv2:
                self.inOut(dCls, ear, skin, eye)
        if (self.dPermitter.getPermissionLevel() > 1):
            # only works with owner
            for dCls in self.dClassesLv3:
                self.inOut(dCls, ear, skin, eye)
        self.fusion.setAlgQueue(self.noiron)
        return self.translateOut(self.fusion.act(ear, skin, eye))

    def getSoulEmotion(self) -> str:
        return self.kokoro.getEmot()

    def getEmot(self) -> str:
        # emot (emotion for display)
        x1: str = self.emot
        return x1

    def inOut(self, dClass: DiSkillV2, ear: str, skin: str, eye: str):
        dClass.input(ear, skin, eye)  # new
        dClass.output(self.noiron)

    def translateIn(self, earIn: str) -> str:
        # makes sure the chobit doesn't feedback on her own output
        if (earIn == self.lastOutput):
            return ""
        return earIn

    def translateOut(self, outResult: str) -> str:
        # save last output served
        if (outResult != ""):
            self.lastOutput = outResult
            self.timeGate.open(20)
            self.kokoro.standBy = False
        # standBy :
        else:
            if (self.timeGate.isClosed()):
                self.kokoro.standBy = True
                self.timeGate.open(5)
            else:
                self.kokoro.standBy = False
        return outResult

    # Override
    def think(self, ear: str, skin: str, eye: str) -> str:
        return self.doIt(ear, skin, eye)

    def getStandby(self) -> bool:
        return self.kokoro.standBy
 

fukurou

the supreme coder
ADMIN
Python:
''' CHOBITSV2 CLASS '''


class ChobitV2(Thinkable):

    def __init__(self, personality: Personality):
        super().__init__()
        self.emot: str = ""  # emotion
        self.dClassesLv1: list[DiSkillV2] = personality.getdClassesLv1()
        self.dClassesLv2: list[DiSkillV2] = personality.getdClassesLv2()  # can engage with friends and work related
        self.dClassesLv3: list[DiSkillV2] = personality.getdClassesLv3()  # can engage only by user
        self.dClassesAuto: list[DiSkillV2] = []  # automatically added and engaged by time
        # algorithms fusion (polymarization)
        self.AlgDurations: dict[str, int] = personality.getAlgDurations()
        self.fusion: Fusion = personality.getFusion()
        # region essential DClasses
        self.permission: Permission = personality.getPermission()
        self.dPermitter: DPermitter = personality.getdPermitter()
        # endregion
        self.noiron: Neuron = Neuron()
        # added :
        self.kokoro: Kokoro = personality.getKokoro()  # soul
        self.lastOutput: str = ""
        # standBy phase 260320
        self.timeGate: ZeroTimeGate = ZeroTimeGate(5)
        self.formAutoClassesList()

    def loadPersonality(self, personality: Personality):
        self.AlgDurations = personality.getAlgDurations()
        self.fusion = personality.getFusion()
        self.kokoro = personality.getKokoro()
        self.permission = personality.getPermission()
        self.dPermitter = personality.getdPermitter()
        self.noiron = Neuron()
        self.dClassesLv1 = personality.getdClassesLv1()
        self.dClassesLv2 = personality.getdClassesLv2()
        self.dClassesLv3 = personality.getdClassesLv3()
        self.dClassesAuto = []
        self.formAutoClassesList()

    def formAutoClassesList(self):
        # adds automatic skills so they can be engaged by time
        for dCls in self.dClassesLv2:
            if (dCls.auto()):
                self.dClassesAuto.append(dCls)
        for dCls in self.dClassesLv3:
            if (dCls.auto()):
                self.dClassesAuto.append(dCls)

    def doIt(self, ear: str, skin: str, eye: str) -> str:
        ear = self.translateIn(ear)
        for dCls in self.dClassesAuto:
            self.inOut(dCls, "", skin, eye)
        for dCls in self.dClassesLv1:
            self.inOut(dCls, ear, skin, eye)
        if (self.dPermitter.getPermissionLevel() > 0):
            # works with friends
            for dCls in self.dClassesLv2:
                self.inOut(dCls, ear, skin, eye)
        if (self.dPermitter.getPermissionLevel() > 1):
            # only works with owner
            for dCls in self.dClassesLv3:
                self.inOut(dCls, ear, skin, eye)
        self.fusion.setAlgQueue(self.noiron)
        return self.translateOut(self.fusion.act(ear, skin, eye))

    def getSoulEmotion(self) -> str:
        return self.kokoro.getEmot()

    def getEmot(self) -> str:
        # emot (emotion for display)
        x1: str = self.emot
        return x1

    def inOut(self, dClass: DiSkillV2, ear: str, skin: str, eye: str):
        dClass.input(ear, skin, eye)  # new
        dClass.output(self.noiron)

    def translateIn(self, earIn: str) -> str:
        # makes sure the chobit doesn't feedback on her own output
        if (earIn == self.lastOutput):
            return ""
        return earIn

    def translateOut(self, outResult: str) -> str:
        # save last output served
        if (outResult != ""):
            self.lastOutput = outResult
            self.timeGate.open(20)
            self.kokoro.standBy = False
        # standBy :
        else:
            if (self.timeGate.isClosed()):
                self.kokoro.standBy = True
                self.timeGate.open(5)
            else:
                self.kokoro.standBy = False
        return outResult

    # Override
    def think(self, ear: str, skin: str, eye: str) -> str:
        return self.doIt(ear, skin, eye)

    def getStandby(self) -> bool:
        return self.kokoro.standBy
 
Top