def main(): log.info('Loading %s...', TicTacToeGame.__name__) g = TicTacToeGame() log.info('Loading %s...', nn.__name__) nnet = nn(g) if args.load_model: log.info(f'Loading checkpoint "{args.load_folder_file}" ...') nnet.load_checkpoint(args.load_folder_file[0], args.load_folder_file[1]) else: log.warning('Not loading a checkpoint!') log.info('Loading the Coach...') c = Coach(g, nnet, args) if args.load_model: log.info("Loading 'trainExamples' from file...") c.loadTrainExamples() log.info('Starting the learning process 🎉') c.learn()
# all players #rp = RandomPlayer(g).play if gameChoice == 0: gp = GreedyOthelloPlayer(g).play hp = HumanOthelloPlayer(g).play elif gameChoice == 1: hp = HumanTicTacToePlayer(g).play elif gameChoice == 2: hp = HumanNimPlayer(g).play # nnet players if gameChoice == 0: n1 = NNet(g) else: n1 = nn(g) if gameChoice == 0: if mini_othello: n1.load_checkpoint('./pretrained_models/othello/pytorch/', '6x100x25_best.pth.tar') else: n1.load_checkpoint('./pretrained_models/othello/pytorch/', '8x8_100checkpoints_best.pth.tar') elif gameChoice == 1: n1.load_checkpoint( '/Users/mettinger/github/alpha-zero-general/pretrained_models/tictactoe/keras', 'best-25eps-25sim-10epch.pth.tar') elif gameChoice == 2: n1.load_checkpoint('''/Users/mettinger/Google Drive/models''', 'best.pth.tar')
25, 'tempThreshold': 15, 'updateThreshold': 0.55, 'maxlenOfQueue': 200000, 'numMCTSSims': 25, 'arenaCompare': 50, 'cpuct': 1, 'checkpoint': './temp/tictactoe/', 'load_model': False, 'load_folder_file': ('./models/tictactoe/10x25x25', 'best.pth.tar'), }) if __name__ == "__main__": g = TicTacToeGame() nnet = nn(g) if args.load_model: nnet.load_checkpoint(args.load_folder_file[0], args.load_folder_file[1]) c = Coach(g, nnet, args) c.learn()
from utils import * """ use this script to play any two agents against each other, or play manually with any agent. """ human_vs_cpu = True g = TicTacToeGame() # all players rp = RandomPlayer(g).play hp = HumanTicTacToePlayer(g).play # nnet players n1 = nn(g) n1.load_checkpoint('./pretrained_models/tictactoe/keras/', 'best-25eps-25sim-10epch.pth.tar') args1 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0}) mcts1 = MCTS(g, n1, args1) n1p = lambda x: np.argmax(mcts1.getActionProb(x, temp=0)) if human_vs_cpu: player2 = hp else: n2 = nn(g) n2.load_checkpoint('./pretrained_models/othello/pytorch/', '8x8_100checkpoints_best.pth.tar') args2 = dotdict({'numMCTSSims': 50, 'cpuct': 1.0}) mcts2 = MCTS(g, n2, args2) n2p = lambda x: np.argmax(mcts2.getActionProb(x, temp=0))