-
Notifications
You must be signed in to change notification settings - Fork 0
/
Play Agent.py
54 lines (43 loc) · 1.39 KB
/
Play Agent.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
'''# Play Agent
Launch the game under control of one of the trained agents.
Graphics are enabled so you can watch it play
'''
from Train import worker
import pickle
def play_top_agent():
'''# Play Top Agent
Play replay for the top agent of the generation'''
with open(r'.\trained_agents\top_agent.pickle', 'rb') as f:
agent = pickle.load(f)
worker(agent, graphics=True)
def play_best_agent():
'''# Play Best Agent
Play replay for the best agent of the training session'''
with open(r'.\trained_agents\best_agent.pickle', 'rb') as f:
agent = pickle.load(f)
worker(agent, graphics=True)
def play_agent(filepath):
'''# Play Agent
Play replay for a saved agent
### Args:
- filepath: filepath to an agent'''
with open(filepath, 'rb') as f:
agent = pickle.load(f)
worker(agent, graphics=True)
def main():
print('1. Pre-Trained Agent\n2. Best Agent\n3. Top Agent\n4. Exit')
inp = input('please select: ')
if inp == '1':
play_agent(r'.\trained_agents\pre_trained.pickle')
elif inp == '2':
play_top_agent()
elif inp == '3':
play_best_agent()
elif inp == '4':
print('Goodbye!')
return
else:
print('\nSelection not supported, please choose 1,2,3,4.')
main()
if __name__ == '__main__':
main()