def look_ahead(self, opponent, rounds = 10): """Plays a number of rounds to determine the best strategy.""" results = [] game = Game() round_robin = RoundRobin(players=[self, opponent], game=game, turns=rounds) strategies = ['C', 'D'] dummy_history_self = copy.copy(self.history) dummy_history_opponent = copy.copy(opponent.history) for strategy in strategies: self.simulate_match(opponent, strategy, rounds) results.append(round_robin.calculate_scores(self, opponent)[0]) self.history = copy.copy(dummy_history_self) opponent.history = copy.copy(dummy_history_opponent) return strategies[results.index(max(results))]
def look_ahead(self, opponent, rounds=10): """Plays a number of rounds to determine the best strategy.""" results = [] game = Game() round_robin = RoundRobin(players=[self, opponent], game=game, turns=rounds) strategies = ['C', 'D'] dummy_history_self = copy.copy(self.history) dummy_history_opponent = copy.copy(opponent.history) for strategy in strategies: self.simulate_match(opponent, strategy, rounds) results.append(round_robin.calculate_scores(self, opponent)[0]) self.history = copy.copy(dummy_history_self) opponent.history = copy.copy(dummy_history_opponent) return strategies[results.index(max(results))]