-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistics.py
27 lines (23 loc) · 1.03 KB
/
statistics.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
class Statistics:
def __init__(self, dqn):
self.reset(0)
self.dqn = dqn
def update(self, action, reward, terminal, epsilon):
self.reward += reward
self.max_reward = max(self.max_reward, reward)
self.min_reward = min(self.min_reward, reward)
self.epsilon = epsilon
if terminal:
self.num_games += 1
def reset(self, epoch):
self.epoch = epoch
self.num_games = 1
self.reward = float(0)
self.max_reward = 0
self.min_reward = 0
def display(self):
print('Epoch {}, num_games {}, average reward {}, learning rate {}'.format(self.epoch,
self.num_games,
self.reward / self.num_games,
self.epsilon))
self.dqn.add_statistics(self.epoch, self.num_games, self.reward/self.num_games)