def est_active(file_list, name): est = np.zeros((days, 2)) ind = 0 for files in file_list: for d in range(1, days): y = estimate(aiwolfpy.read_log(files), d, name) if y >= 0: est[d, 0] += y est[d, 1] += 1 n_est = int(est[1, 1]) if n_est % 100 == 0: print('est_{}files = {:.2f}[sec]'.format(n_est, time.time() - start1)) return est
def data_active(file_list, expan): x, y = xy_init(expan, file_list) ind = 0 for files in file_list: gamedf = aiwolfpy.read_log(files) for i in range(expan): df = gamedf_expansion(gamedf) for d in range(1, days): dx, dy = get_data(df, d) x[(ind * 60):((ind + 1) * 60), :] = dx y[(ind * 60):((ind + 1) * 60)] = dy ind += 1 n_data = int(ind / (days - 1)) if n_data % 100 == 0: print('get_{}data = {:.2f}[sec]'.format( n_data, time.time() - start1)) return x, y
count = 0 model = sklearn.linear_model.LogisticRegression() wf = open("/home/AIWolfPy/train/train-log2.txt", mode="a") for k in range(21, 1000): x_1000 = np.zeros((5460000, 60)) y_1000 = np.zeros(5460000) ind = 0 for i in range(100): log_path = "/home/AIWolfPy/pre_logs/gat2017_15/" + "{0:03d}".format( k) + "/" + "{0:03d}".format(i) + ".log" for d in range(5): try: text_ = aiwolfpy.read_log(log_path) except: continue x, y = game_data_filter(text_, day=d, phase='vote') x_1000[(ind * 5460):((ind + 1) * 5460), :] = x y_1000[(ind * 5460):((ind + 1) * 5460)] = y ind += 1 x, y = game_data_filter(text_, day=d + 1, phase='daily_initialize') x_1000[(ind * 5460):((ind + 1) * 5460), :] = x y_1000[(ind * 5460):((ind + 1) * 5460)] = y ind += 1 model.fit(x_1000, y_1000) text = "epoch :" + str(count) + " score :" + str( model.score(x_1000, y_1000)) print(text) wf = open("/home/AIWolfPy/train/train-log.txt", mode="a")
train_num = len(train_file) test_num = len(test_file) days = 3 expan = 30 x_data = np.zeros((60 * days * train_num * expan, predictor.n_para)) y_data = np.zeros(60 * days * train_num * expan) start1 = time.time() ind = 0 for files in train_file: for i in range(expan): a = random.randint(0, 119) for d in range(days): x, y = game_data_filter(aiwolfpy.read_log(files), day=d, pat=a) x_data[(ind * 60):((ind + 1) * 60), :] = x y_data[(ind * 60):((ind + 1) * 60)] = y ind += 1 if (ind / days) % 100 == 0: print('get_{}data = {}[sec]'.format(int(ind / days), time.time() - start1)) print("get_train_data = {}[sec]".format(time.time() - start)) train_file = file_list[:500] test_file = file_list[500:1000] train_num = len(train_file) test_num = len(test_file) times = 10
break """ # build data for 100 games # takes several minutes x_1000 = np.zeros((5460000, 60)) y_1000 = np.zeros(5460000) ind = 0 filecount = 0 for i in range(999999): #log_path = "../log/sample13/AIWolf20191002" + "{0:03d}".format(def_file_no+i) + ".log" log_path = "../../Server/AIWolf-ver0.5.6/log/sample21/AIWolf20191002" + "{0:03d}".format( i) + ".log" for d in range(5): try: x, y = game_data_filter(aiwolfpy.read_log(log_path), day=d, phase='vote') x_1000[(ind * 5460):((ind + 1) * 5460), :] = x y_1000[(ind * 5460):((ind + 1) * 5460)] = y ind += 1 x, y = game_data_filter(aiwolfpy.read_log(log_path), day=d + 1, phase='daily_initialize') x_1000[(ind * 5460):((ind + 1) * 5460), :] = x y_1000[(ind * 5460):((ind + 1) * 5460)] = y ind += 1 if d == 0: filecount += 1 except FileNotFoundError: break