-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
29 lines (20 loc) · 775 Bytes
/
plot.py
File metadata and controls
29 lines (20 loc) · 775 Bytes
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
import matplotlib.pyplot as plt
from IPython import display
plt.ion()
def plot(scores, mean_scores):
display.clear_output(wait=True)
fig = plt.gcf()
fig.canvas.manager.set_window_title('DRL Snake Game Plot')
display.display(plt.gcf()) # GCF = Get Current Figure
plt.clf() # Clear Current Figure (Refresh)
plt.title('Training Snake Game AI...')
plt.xlabel('Number of Games')
plt.ylabel('Score')
plt.plot(scores, label='Scores')
plt.plot(mean_scores, label='Mean Scores')
plt.ylim(ymin=0) # Y-Limits
plt.legend()
plt.text(len(scores)-1, scores[-1], str(scores[-1])) # Last Score
plt.text(len(mean_scores)-1, mean_scores[-1], str(mean_scores[-1])) # Last Mean Score
plt.show(block=False)
plt.pause(2)