def main_experiments(player: Player = None): logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) colors = list(Color) colors.remove(Color.EMPTY) possible_codes = [p for p in itertools.product(colors, repeat=4)] if player is None: player = SmartPlayer(strategy=SmartStrategy.FIRST) rounds = [] for possible_code in possible_codes: start = datetime.datetime.now() # print(possible_code) code = Code(*possible_code) player.reset() round = player.play_game(50, code) rounds.append(round + 1) end = datetime.datetime.now() print(f"Code: {possible_code}, time: {end - start}, rounds: {round + 1}") print(f"Number of games: {len(rounds)}") print(f"Mean: {np.mean(rounds)}") print(f"Max: {max(rounds)}") print(f"Min: {min(rounds)}") return np.mean(rounds), max(rounds)
def fastTurn(player1: Player, player2 : Player, max_turn : int, mistakeRate: int): """Play all the turns between two player without printing trace :param player1: Player 1 :param player2: Player 2 :param max_turn: The number of turn of a confrontation :return: None """ n = 0 while n < max_turn : if n == 0: player1.play('C', mistakeRate) player2.play('C', mistakeRate) else : player1.play(player2.choice[-1], mistakeRate) player2.play(player1.choice[-2], mistakeRate) gain(player1, player2, False) n+= 1 print("Player", player1.name, ":", player1.get_score(), "\nPlayer {} : {}\n".format(player2.name, player2.get_score())) # Empty the players' list of choice for next match player1.reset() player2.reset()
def reset(self): Player.reset(self) self.__wasBetrayed = False
def reset(self): Player.reset(self) self.choice = ['C']
def reset(self): Player.reset(self) self.__actLikeCopycat = False
def reset(self): Player.reset(self) self.__isOnGrudge = False self.__nbBetrayal = 0 self.__grudgeCount = 0
def reset(self): Player.reset(self) self.__grudge = False