-
Notifications
You must be signed in to change notification settings - Fork 79
/
runner.py
executable file
·187 lines (143 loc) · 3.93 KB
/
runner.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/env python
import os
import sys
import subprocess
from phillip import util
from collections import OrderedDict
import argparse
import random
parser = argparse.ArgumentParser()
parser.add_argument("--tag", action="store_true", help="generate random tag for this experiment")
parser.add_argument("--name", type=str, help="experiment name")
args = parser.parse_args()
if args.tag:
exp_name = str(random.getrandbits(32)) + "_"
else:
exp_name = ""
params = OrderedDict()
def toStr(val):
if isinstance(val, list):
return "_".join(map(str, val))
return str(val)
def add_param(param, value, name=True):
global exp_name
if name and value:
if isinstance(value, bool):
exp_name += "_" + param
else:
exp_name += "_" + param + "_" + toStr(value)
params[param] = value
model = 'ActorCritic'
exp_name += model
recurrent = True
# add_param('policy', model, False)
add_param('epsilon', 0.005, False)
natural = True
natural = False
#natural = ac
#add_param('optimizer', 'Adam', False)
#add_param('learning_rate', 1e-4, False),
add_param('sweeps', 1, False)
add_param('batch_size', 64, False)
add_param('batch_steps', 1, False)
add_param("max_buffer", 64, False)
add_param('min_collect', 32, False)
add_param('reward_halflife', 4, False)
#add_param('dynamic', 0)
# evolution
evolve = False
#evolve = True
if evolve:
add_param("evolve", True, False)
add_param("pop_size", 4)
add_param("reward_cutoff", 2e-4, False)
add_param("evo_period", 4000, False)
add_param("evolve_entropy", True, False)
add_param("evolve_learning_rate", True, False)
add_param("reward_decay", 2e-4, False)
# add_param('explore_scale', 1e-4)
delay = 2
predict_steps = 0
#predict_steps = delay
if predict_steps:
add_param('predict_steps', predict_steps)
add_param('predict', True, False)
add_param('model_weight', .1, False)
add_param('model_layers', [256], False)
add_param('train_model', True, False)
# add_param('train_only_last', True, True)
add_param('core_layers', [256], False)
add_param('actor_layers', [128], False)
add_param('critic_layers', [128], False)
#add_param('train_policy', True)
#add_param('train_critic', False)
#add_param('entropy_power', 0)
add_param('entropy_scale', 1e-3, False)
if recurrent:
# add_param('clip', 0.05)
add_param('recurrent', True)
add_param('initial', 'train', False)
add_param('gae_lambda', 1., False)
#add_param('retrace', True)
add_param('unshift_critic', True, True)
# embed params
add_param('xy_scale', 0.05, False)
#add_param('speed_scale
add_param('action_space', 0, False)
add_param('player_space', 0, False)
#add_param('critic_layers', [128] * 1)
#add_param('actor_layers', [128] * 3)
add_param('nl', 'elu', False)
add_param('action_type', 'custom', False)
add_param('fix_scopes', True, False)
# agent settings
#add_param('dolphin', True, False)
add_param('experience_length', 80, False)
add_param('reload', 1, False)
#char = 'falco'
#char = 'sheik'
char = 'falcon'
#char = 'marth'
#char = 'fox'
#char = 'peach'
#char = 'luigi'
#char = 'samus'
#char = 'ganon'
#char = 'puff'
#char = 'bowser'
#char = 'dk'
from phillip import data
#act_every = 2
act_every = data.short_hop[char]
add_param('act_every', act_every, False)
if delay:
add_param('delay', delay)
if not recurrent:
add_param('memory', 1)
#add_param('memory', 0, False)
stage = 'battlefield'
#stage = 'final_destination'
add_param('stage', stage, False)
add_param('char', char, True)
enemies = None
enemies = "cpu"
#enemies = "easy"
#enemies = "delay0"
#enemies = "delay%d" % delay
#enemies = ['self']
#enemies = 'hard-self'
add_param('enemies', enemies)
add_param('enemy_reload', 3600, False)
# total number of agents
agents = 80
params['agents'] = agents
if args.name is not None:
exp_name = args.name
add_param('name', exp_name, False)
path = "saves/%s/" % exp_name
#add_param('path', path, False)
print("Writing to", path)
util.makedirs(path)
import json
with open(path + "params", 'w') as f:
json.dump(params, f, indent=2)