clear = True propnets = dict() expertModels = dict() gameData = dict() players = dict() totalRounds = 1601 rotateEvery = 50 replay_buffer = dict() for game in expertGames: replay_buffer[game] = pickle.load(open( "buffers/" + game + "2500for400rounds.p", "rb" ) ) data, propnet = load_propnet(to_game) mnModel = Model(propnet, multiNet=True, games=expertGames, replay_buffer=replay_buffer) if clear: print("CLEARING") mnModel.clear_output_layer() ## train cur = [None] mnModel.save(to_game,0,multiNet=True) start = time.time() gameIndex = 0 for i in range(totalRounds+1): if i % rotateEvery == 0: gameIndex = (gameIndex + 1) % len(expertGames)
#!/usr/bin/env python3.7 import sys sys.path.insert(1, '/Users/Cameron/Desktop/transfer_ggp') from model import Model from mcts import MCTSNode, simulation from propnet.propnet import load_propnet import time start = time.time() # propnet = load_propnet('connect4match1') # propnet = load_propnet('tictactoe1') data, propnet = load_propnet('connectFour') root = MCTSNode(propnet, data) # exit(0) for i in range(400): simulation(root) root.print_node() print('Took', time.time() - start, 'seconds')
from model import Model from utils.pauser import set_pauser import time import sys import tensorflow as tf import re import pickle if len(sys.argv) < 4: print("Usage: transfer.py <game> <ckpt> <total_rounds>") game = sys.argv[1] expertckpt = sys.argv[2] totalRounds = int(sys.argv[3]) data, propnet = load_propnet(game) m = Model(propnet, create=False) m.load('./models/' + game + '/step-%06d.ckpt' % int(expertckpt)) cur = [None] start = time.time() gameIndex = 0 for i in range(totalRounds + 1): cur[0] = B1Node(propnet, data, model=m) print('Game number', i) start_game = time.time() do_game(cur, propnet, m, z=0.5) print("took ", time.time() - start_game, "seconds to play game") pickle.dump(
role_a = ('black',) role_b = ('white',) if 'breakthrough-6x6' in from_game.lower(): bd = [5650, 2825, 1412, 706, 353, 176, 88, 50] rd = [] elif 'breakthroughSmall' in from_game.lower(): bd = [2070, 1035, 517, 258, 129, 64, 50] rd = [] elif 'connect' in from_game.lower(): role_a = ('red',) role_b = ('white',) bd = [685, 342, 171, 85, 50] rd = [] ## load propnet for new game oldData, old_prop = load_propnet(from_game) ## load propnet for old game data, new_prop = load_propnet(to_game) ## check dimensions of the input and output layers oldPropNumActions = {role: len(actions) for role, actions in old_prop.legal_for.items()} newPropNumActions = {role: len(actions) for role, actions in new_prop.legal_for.items()} if (len(old_prop.roles) == len(new_prop.roles) and oldPropNumActions == newPropNumActions and len(old_prop.propositions) == len(new_prop.propositions)): model = Model(new_prop, create=False) model.load('./models/' + from_game + '/step-%06d.ckpt' % int(ckpt))