-
Notifications
You must be signed in to change notification settings - Fork 0
/
plots.py
53 lines (48 loc) · 1.7 KB
/
plots.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
import matplotlib.pyplot as plt
from typing import List
def plot_episode_rewards(avg_rewards: List[float]) -> None:
"""
Plot the average accumulated rewards per episode.
"""
plt.plot(range(1, len(avg_rewards) + 1), avg_rewards)
plt.xlabel('Episodes')
plt.ylabel('Accumulated Reward')
plt.title('Average Accumulated Rewards Per Episode')
plt.grid(True)
plt.show()
def plot_agent_rewards(agent_rewards: List[float], weight: float) -> None:
"""
Plot the average episode rewards per agent.
"""
plt.plot(range(1, len(agent_rewards) + 1), agent_rewards)
plt.xlabel('Episodes')
plt.ylabel('Reward')
plt.title(f'Average Episode Reward Per Agent ({weight} weight)')
plt.grid(True)
plt.show()
def plot_mistakes_per_episode(mistakes_per_turn: List[int]) -> None:
"""
Plot the average mistakes per episode.
"""
plt.plot(range(1, len(mistakes_per_turn) + 1), mistakes_per_turn)
plt.xlabel('Episodes')
plt.ylabel('Mistakes')
plt.title('Average Mistakes Per Episode')
plt.grid(True)
plt.show()
def plot_reward_per_tile(pos_1: List[float], pos_2: List[float], pos_3: List[float], pos_4: List[float]) -> None:
"""
Plot the rewards of each tile per turn.
"""
turns = range(len(pos_1))
plt.plot(turns, pos_1, label='Reward of 1st tile')
plt.plot(turns, pos_2, label='Reward of 2nd tile')
plt.plot(turns, pos_3, label='Reward of 3rd tile')
plt.plot(turns, pos_4, label='Reward of 4th tile')
plt.xlabel('Turns')
plt.ylabel('Reward')
plt.title('Reward of tile per turn')
plt.legend()
plt.show()
if __name__ == '__main__':
print('plotting utils')