def main(): log.info('Loading %s...', Game.__name__) g = Game() log.info('Loading %s...', nn.__name__) nnet = nn(g) if args.load_model: log.info('Loading checkpoint "%s/%s"...', 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()
500, 'arenaTemp': 0.1, 'arenaMCTS': False, 'randomCompareFreq': 1, 'compareWithPast': True, 'pastCompareFreq': 3, 'expertValueWeight': dotdict({ 'start': 0, 'end': 0, 'iterations': 35 }), 'cpuct': 3, 'checkpoint': 'checkpoint', 'data': 'data', }) if __name__ == "__main__": g = Game() nnet = nn(g) c = Coach(g, nnet, args) c.learn()
'arenaCompare': 40, # Number of games to play during arena play to determine if new net will be accepted. 'cpuct': 2.0, 'checkpoint': './temp/', 'load_model': False, 'load_folder_file': ( './temp/', #'/dev/models/8x100x50', 'best.pth.tar'), 'numItersForTrainExamplesHistory': 20, }) if __name__ == "__main__": #g = Game(5,5,3) # mini g = Game(6, 7, 4) nnet = nn(g) if args.load_model: print("--------- Loading ----------------") nnet.load_checkpoint(args.load_folder_file[0], args.load_folder_file[1]) c = Coach(g, nnet, args) if args.load_model: print("Load trainExamples from file") c.loadTrainExamples() c.learn()
from utils import * args = dotdict({ 'numIters': 1000, 'numEps': 100, 'tempThreshold': 15, 'updateThreshold': 0.6, 'maxlenOfQueue': 200000, 'numMCTSSims': 25, 'arenaCompare': 40, 'cpuct': 1, 'checkpoint': './temp/', 'load_model': False, 'load_folder_file': ('/dev/models/8x100x50', 'best.pth.tar'), 'numItersForTrainExamplesHistory': 20, }) if __name__ == "__main__": g = Game(6) 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) if args.load_model: print("Load trainExamples from file") c.loadTrainExamples() c.learn()
from connect4.Connect4Game import Connect4Game as Game from connect4.Connect4Players.HumanPlayer import HumanConnect4Player from connect4.Connect4Players.RandomPlayer import RandomPlayer from connect4.Connect4Players.MinimaxPlayer import MinimaxPlayer from connect4.Connect4Players.YOURTEAMPlayer import YOURTEAMPlayer import Arena """ use this script to play any two agents against each other, or play manually with any agent. """ human_vs_cpu = True g = Game(visualize=True) # all players rp = RandomPlayer(g).play hp = HumanConnect4Player(g).play mm4p = MinimaxPlayer(g, depth=4, randomized=True).play mm5p = MinimaxPlayer(g, depth=5, randomized=True).play ytp = YOURTEAMPlayer(g).play arena = Arena.Arena(mm5p, mm4p, g) """ result, times = arena.playGame(verbose=True) if result == 1: print("P1 won") else: print("P2 won")z """