def play(self, otherChoice, mistakeRate): if self.__isOnGrudge: if self.__grudgeCount == 0: self.__grudgeCount = -2 self.__isOnGrudge = False self.choice.append('C') else: self.choice.append('B') self.__grudgeCount -= 1 else: if otherChoice == 'B': if self.__grudgeCount == 0: # Betrayal during a normal cooperation self.startGrudge() self.choice.append('B') elif self.__grudgeCount < 0: # Betrayal during the 2 turns of forgiveness self.__grudgeCount += 1 if self.__grudgeCount == 0: # If it was the last turn of forgiveness, prepare the next punition self.startGrudge() self.choice.append('C') else: # both cooperating if self.__grudgeCount < 0: # update the count of forgiveness turns self.__grudgeCount += 1 self.choice.append('C') Player.apply_mistake_rate(self, mistakeRate)
def play(self, otherChoice, mistakeRate): if len(self.choice) == 0 : self.choice.append('C') else : if otherChoice == 'B': self.__grudge = True if self.__grudge: self.choice.append('B') else : self.choice.append('C') Player.apply_mistake_rate(self, mistakeRate)
def play(self, otherChoice, mistakeRate): if otherChoice == 'B': if self.__wasBetrayed: self.choice.append('B') else: self.__wasBetrayed = True self.choice.append('C') else: if self.__wasBetrayed: self.__wasBetrayed = False self.choice.append('C') Player.apply_mistake_rate(self, mistakeRate)
def play(self, otherChoice, mistakeRate): if len(self.choice) == 0: self.choice.append('C') elif len(self.choice) < 4: if 'B' == otherChoice: self.__actLikeCopycat = True if len(self.choice) == 1: self.choice.append('B') else: self.choice.append('C') else: if self.__actLikeCopycat: Copycat.play(self, otherChoice, mistakeRate) else: self.choice.append('B') Player.apply_mistake_rate(self, mistakeRate)
def play(self, otherChoice, mistakeRate): if len(self.choice) != 0: self.choice.append(otherChoice) Player.apply_mistake_rate(self, mistakeRate)
def play(self, otherChoice, mistakeRate): self.choice.append('B') Player.apply_mistake_rate(self, mistakeRate)