''' Chobits CLASS '''
class Chobits(Thinkable):
def __init__(self):
super().__init__()
self.emot: str = "" # emotion
self.dClasses: list[DiSkillV2] = []
# algorithms fusion (polymarization)
self.algDurations: dict[str, int] = {}
self.fusion: Fusion = Fusion(self.algDurations)
self.noiron: Neuron = Neuron()
# added :
self.kokoro: Kokoro = Kokoro(AbsDictionaryDB()) # soul
self.lastOutput: str = ""
# standBy phase 260320
self.timeGate: TimeGate = TimeGate(5)
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