if args.file2: if os.path.exists(args.file2): with open(args.file2, 'rb') as fp: state_dict2 = pickle.load(fp) else: state_dict2 = {} for i in range(args.n): tictactoe = TicTacToe() Player1 = RLTicTacToeAgent(tictactoe, state_dict1) Player2 = RandomTicTacToeAgent(tictactoe) tictactoe.add_agent(Player1, 'x') tictactoe.add_agent(Player2, 'o') while not tictactoe.game_has_ended()[0]: next_move1 = Player1.emit_move() tictactoe.move(next_move1) if not tictactoe.game_has_ended()[0]: next_move2 = Player2.emit_move() tictactoe.move(next_move2) if args.verbose: who_won = tictactoe.game_has_ended()[1] if who_won == 'draw': print("Draw!") elif who_won == 'x': print("Won!")