import rpstournament import random #Your class must be called GamePlayer, and it must have these functions class GamePlayer: #Give your AI a name. You can put your name in it or not, depending on whether you want to be anonymous. #You can submit multiple AI's with different names for the tournament name = "Tiger Shark" def __init__ (self): self.score = 1 self.opponentScore = 0 self.opponent_choice = "" self.choices = ["rock", "paper", "scissors"] self.toggle = True self.changeRound = 3 self.choice = "" self.previousWinRate = 1 def make_choice(self): self.choice = random.choice(self.choices) return self.choice def view_opponent_choice(self, opponent_choice): self.opponent_choice = opponent_choice #print((self.score + 1) / (self.opponentScore + 1)) #print(self.score / (self.score + self.opponentScore)) if self.score / (self.score + self.opponentScore) < 0.6 and (self.score + self.opponentScore) % self.changeRound == 0 and self.previousWinRate > self.score / (self.score + self.opponentScore): self.toggle = not self.toggle self.previousWinRate = self.score / (self.score + self.opponentScore) #print (self.toggle) if not self.toggle: if self.opponent_choice == "rock": self.choices.append("scissors") elif self.opponent_choice == "paper": self.choices.append("rock") else: self.choices.append("paper") else: if self.opponent_choice == "rock": self.choices.append("paper") elif self.opponent_choice == "paper": self.choices.append("scissors") else: self.choices.append("rock") if len(self.choices) > 100: self.choices.pop(0) if self.choice == self.opponent_choice: self.score += 1 self.opponentScore += 1 elif self.choice == "rock" and self.opponent_choice == "scissors" or self.choice == "paper" and self.opponent_choice == "rock" or self.choice == "scissors" and self.opponent_choice == "paper": self.score += 1 else: self.opponentScore += 1 def new_player(self): self.score = 1 self.opponentScore = 0 self.choices = ["rock", "paper", "scissors"] self.toggle = True self.changeRound = 3 return