-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_timetable.py
79 lines (66 loc) · 2.83 KB
/
plot_timetable.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import numpy as np
import matplotlib.pyplot as plt
# load the data
game_players=np.load(r'connect_four_ai\results\game_players_move_ordering_timetable.npy', allow_pickle=True).item() #ended up not needing this
game_timetable=np.load(r'connect_four_ai\results\game_score_move_ordering_timetable.npy',allow_pickle=True).item()
# simply rearranging everything so that we can plot everything correctly
# appending the move times for the games that 'x' agent played
methods=["pv", "ltr", "random", "middle"]
k=0
player_game_timetable={}
for i in methods:
player_game_timetable[i]=[]
for i in range(4):
iterator=[x for x in range(4) if x != i]
for j in iterator:
player1, method1=1, methods[i]
player2, method2=2, methods[j]
player_game_timetable[method1].append(game_timetable[f'game{k}'][player1]) #its predictable always player1 is the player looping over i
player_game_timetable[method2].append(game_timetable[f'game{k}'][player2]) # player2 is the player looping over j
k+=1
# plot all the move times for all games and all agents
for i in range(len(player_game_timetable['pv'])):
plt.plot(player_game_timetable['pv'][i], color='red')
plt.plot(player_game_timetable['ltr'][i], color='pink')
plt.plot(player_game_timetable['random'][i], color='gray')
plt.plot(player_game_timetable['middle'][i], color='skyblue')
plt.xlabel('agent move #')
plt.ylabel('move time (s)')
plt.xticks(range(0,20,5))
plt.suptitle('Comparing move time for agent with different move orders')
plt.legend(['principle-of-variation', 'left-to-right', 'random', 'middle'])
plt.show()
plt.savefig(r'connect_four_ai\results\Figure_1.png')
# plotting the move times for each agent separately
plt.suptitle('Move time for agent with different move orders')
for i in range(len(player_game_timetable['pv'])):
plt.subplot(2,2,1)
plt.plot(player_game_timetable['pv'][i], color='red')
#plt.xlabel('agent move #')
plt.ylabel('move time (s)')
plt.xticks(range(0,20,5))
plt.ylim(0,50)
plt.legend(['principle-of-variation'], fontsize=8)
plt.subplot(2,2,2)
plt.plot(player_game_timetable['ltr'][i], color='pink')
#plt.xlabel('agent move #')
#plt.ylabel('move time (s)')
plt.xticks(range(0,20,5))
plt.ylim(0,50)
plt.legend(['left-to-right'], fontsize=8)
plt.subplot(2,2,3)
plt.plot(player_game_timetable['random'][i], color='gray')
plt.xlabel('agent move #')
plt.ylabel('move time (s)')
plt.xticks(range(0,20,5))
plt.ylim(0,50)
plt.legend(['random'], fontsize=8)
plt.subplot(2,2,4)
plt.plot(player_game_timetable['middle'][i], color='skyblue')
plt.xlabel('agent move #')
#plt.ylabel('move time (s)')
plt.xticks(range(0,20,5))
plt.ylim(0,50)
plt.legend(['middle'], fontsize=8)
plt.show()
plt.savefig(r'connect_four_ai\results\Figure_2.png')