def test_p1(subject): temp = GameManager(prev_player=subject, train=False) loss = 0 wins = 0 for i in range(10000): temp.simulate() if temp.check_win() == 2: loss += 1 else: wins += 1 temp.reset() return (wins / (wins + loss)) * 100
init_method=init) trials_ = int(input('Enter number of trials: ')) trials = trials_ pbartmp = progressbar.ProgressBar(maxval=1).default_widgets() pbar = progressbar.ProgressBar(widgets=pbartmp[:], maxval=trials) del pbartmp wins = 0 loss = 0 while trials > 0: try: manager.simulate() except Exception as e: print("MENANCE has died") break if manager.check_win() == 2: loss += 1 else: wins += 1 manager.reset() if prune_length != -1 and trials % prune_length == 0: prune(manager.player) pbar.update(trials_ - trials) trials -= 1 pbar.finish() print("Exited with", str((wins / (wins + loss)) * 100) + "% winrate") if train and input("Do you want to dump this instance to disk? (y/n) ") == 'y': loc = input('Location [./instance.p]: ') if loc == '': manager.player.dump()