-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtesting.py
More file actions
54 lines (41 loc) · 1.43 KB
/
testing.py
File metadata and controls
54 lines (41 loc) · 1.43 KB
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
import sys
sys.path.insert(0, 'evoman')
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
from demo_controller import player_controller
from evoman.environment import Environment
plt.style.use('ggplot')
import os
# do not display pygame window
os.environ["SDL_VIDEODRIVER"] = "dummy"
experiment_name = "test_generalist"
def fitness(single_weight_matrix):
f,p,e,t = env.play(pcont=single_weight_matrix)
return p,e
if __name__ == "__main__":
enemies = [1,2,3,4,5,6,7,8]
log = []
for run in range(1, 11):
ctr = np.loadtxt(f'./GENERALIST/EA/run_{run}.txt')
gain = 0
for enemy in enemies:
env = Environment(experiment_name=experiment_name,
enemies=[enemy],
# multiplemode='yes',
playermode="ai",
player_controller=player_controller(),
enemymode="static",
level=2,
speed="fastest",
logs="off")
gain_enemy = 0
for i in range(5):
p, e = fitness(ctr)
g = float(p) - float(e)
gain_enemy += g
gain_enemy /= 5
gain += gain_enemy
log.append(gain)
top10 = pd.DataFrame(log)
top10.to_csv('EA_generalist_gain.csv')