-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterate.py
58 lines (50 loc) · 1.56 KB
/
iterate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import _othello_environment
import _train
import csv
import datetime
import decompose_games
import graphviz
import json
import mcts
import multiprocessing
import oracle
import os
import pandas
import random
import self_generation
import shutil
import subprocess
import time
import variables_info
OUTPUT_PATH = _othello_environment.parameter('OTHELLO_OUTPUT_PATH')
# ===================================================================================
last_filepath = None
for generation in range(6):
os.makedirs(f'{OUTPUT_PATH}/{generation}/plays', exist_ok=True)
os.makedirs(f'{OUTPUT_PATH}/{generation}/models', exist_ok=True)
if generation >= 1:
assert last_filepath is not None
self_generation.self_generate(
model_load_paths = [last_filepath],
plays_path = f'{OUTPUT_PATH}/{generation}/plays',
)
data = {
'model': last_filepath,
}
with open(f'{OUTPUT_PATH}/{generation}/plays/meta.json', 'w') as json_file:
json.dump(data, json_file, indent=2)
if generation == 0:
decompose_games.decompose(
source_path = f'data/othello_dataset.csv',
target_path = f'{OUTPUT_PATH}/0/plays/states.csv',
trajectories_path = f'{OUTPUT_PATH}/0/plays/trajectories.csv',
)
else:
decompose_games.decompose(
source_path = f'{OUTPUT_PATH}/{generation}/plays/trajectories.csv',
target_path = f'{OUTPUT_PATH}/{generation}/plays/states.csv',
)
last_filepath = _train.train(
prediction_prompts_path = f'{OUTPUT_PATH}/{generation}/plays/states.csv',
models_path = f'{OUTPUT_PATH}/{generation}/models',
)