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 main_single(player: Player, code: Code = None): logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) print("ready") if code is None: code = Code(Color.ORANGE, Color.PURPLE, Color.ORANGE, Color.YELLOW) if player is None: player = SmartPlayer() round = player.play_game(50, code) print(round + 1)