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