-
Notifications
You must be signed in to change notification settings - Fork 1
/
avg_map_renderer.py
37 lines (30 loc) · 1 KB
/
avg_map_renderer.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
from game.game import Game
from evo.evo import EvoAlg
from run_log import gen_param_specs
import sys
import json
data_id = sys.argv[1]
with open('{}_log.txt'.format(data_id)) as f:
data = json.load(f)
phistories = {}
for key in data['spec']:
if 'min' in data['spec'][key]:
phistories[key] = []
for pop in data['population_history']:
for key in data['spec']:
arr = [param[key] for param in pop['population']]
if 'min' in data['spec'][key]:
vrange = data['spec'][key]['max'] - data['spec'][key]['min']
value = sum(arr) / len(arr)
if gen_param_specs[key]['dtype'] == int:
value = round(value)
phistories[key].append(value)
last_avg_param = {}
for key in phistories:
last_avg_param[key] = phistories[key][-1]
last_avg_param['enemies_crush_trees'] = True
ea = EvoAlg(gen_param_specs)
env = Game(evo_system=ea)
env.worldgen.level_params = [last_avg_param]
state = env.reset()
env.screenshot('{}_render'.format(data_id))