🐍 python Chii's python suit

python

fukurou

the supreme coder
ADMIN
ChobitsV2

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(5)
            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
PersonalityLight

Python:
''' PERSONALITY Light CLASS '''


class PersonalityLight:
    '''
    this class is used in the ChobitV2 c'tor.
    it enables loading a complete skill set (a sub class of the personality class)
    using 1 line of code. of course you can also select specific skills to add from
    the subclasses c'tor. see also Personality1 for example.
    '''
    '''
    flight or fight skills may need access to the above fusion class booleans
    on the output methode of a skill this skills will load algorithms to the highest priority of the noiron
    which carries algorithms :
    noiron.negativeAlgParts.add(Algorithm)
    '''

    def __init__(self, *absDictionaryDB: AbsDictionaryDB):
        self._dClassesLv1: list[DiSkillV2] = []  # can engage with anyone
        self._AlgDurations: dict[str, int] = {}
        self._fusion: Fusion = Fusion(self._AlgDurations)
        # fusion.getReqOverload() # an overload of requests on the brain
        # fusion.getRepReq() // someone is negging and asking the same thing over and over again
        try:
            if (len(absDictionaryDB) == 1):
                self._kokoro = Kokoro(absDictionaryDB[0])
            else:
                self._kokoro = Kokoro(AbsDictionaryDBShadow())
        except:
            self._kokoro = Kokoro(AbsDictionaryDBShadow())

    def getdClassesLv1(self) -> list[DiSkillV2]:
        return self._dClassesLv1

    def getKokoro(self) -> Kokoro:
        return self._kokoro

    def getAlgDurations(self) -> dict[str, int]:
        return self._AlgDurations

    def getFusion(self) -> Fusion:
        return self._fusion

ChobitsLight

Python:
''' CHOBITSLIGHT CLASS '''


class ChobitsLight(Thinkable):

    def __init__(self, personality: PersonalityLight):
        super().__init__()
        self.emot: str = ""  # emotion
        self.dClassesLv1: list[DiSkillV2] = personality.getdClassesLv1()
        # algorithms fusion (polymarization)
        self.AlgDurations: dict[str, int] = personality.getAlgDurations()
        self.fusion: Fusion = personality.getFusion()
        self.noiron: Neuron = Neuron()
        # added :
        self.kokoro: Kokoro = personality.getKokoro()  # soul
        self.lastOutput: str = ""
        # standBy phase 260320
        self.timeGate: ZeroTimeGate = ZeroTimeGate(5)

    def loadPersonality(self, personality: Personality):
        self.AlgDurations = personality.getAlgDurations()
        self.fusion = personality.getFusion()
        self.kokoro = personality.getKokoro()
        self.noiron = Neuron()
        self.dClassesLv1 = personality.getdClassesLv1()

    def doIt(self, ear: str, skin: str, eye: str) -> str:
        ear = self.translateIn(ear)
        for dCls in self.dClassesLv1:
            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(5)
            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
ChobitsLight test :

Python:
class Personality2(PersonalityLight):
    # Override
    def __init__(self, *absDictionaryDB: AbsDictionaryDB):
        super().__init__(absDictionaryDB)
        super().getdClassesLv1().append(DiHelloWorld(self.getKokoro()))


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

ChobitsV2 test :

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)
 
Top