from AutoPerson import AutoPerson from random import randint class Bipolar(AutoPerson): def __init__(self, name, place, threshold, mood): AutoPerson.__init__(self, name, place, threshold) self.mood = mood # 1 means manic, 0 means depressed def cry(self): self.say("Waaaaahh waaaaahh. I'm sad!") def laugh(self): self.say("Hehehe!") def maybeAct(self): self.mood = randint(0, 1) # have a bout of mood swing AutoPerson.maybeAct(self) def act(self): if self.state == 0: self.cry() else: self.laugh() AutoPerson.act(self)