forked from martius-lab/hockey-env
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremoteDQN.py
executable file
·55 lines (39 loc) · 1.71 KB
/
remoteDQN.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 15 08:05:04 2021
@author: johannes
"""
import sys
import numpy as np
sys.path.append('/home/johannes/Uni/ReinforcementLearning/project/DQN')
from client.remoteControllerInterface import RemoteControllerInterface
from client.backend.client import Client
from DQN.agent import DQNAgent
from laserhockey.hockey_env import HockeyEnv
load_weights = "alg2"
env = HockeyEnv()
class RemoteDQNAgent(DQNAgent):
def __init__(self):
DQNAgent.__init__(self, env.observation_space, env.discrete_action_space,
convert_func = env.discrete_to_continous_action,
pretrained = f'DQN/weights/{load_weights}')
RemoteControllerInterface.__init__(self, identifier='StillTrying_DQN')
def remote_act(self, obs):
return np.asarray(self.act(obs,eps=0))
if __name__ == '__main__':
controller = RemoteDQNAgent()
# Play n (None for an infinite amount) games and quit
client = Client(username='Johannes_Schulz_StillTrying', # Testuser
password='Rba*9UxK',
controller=controller,
output_path='DQN/recorded_games', # rollout buffer with finished games will be saved in here
interactive=False,
op='start_queuing',
num_games=None)
# Start interactive mode. Start playing by typing start_queuing. Stop playing by pressing escape and typing stop_queuing
# client = Client(username='user0',
# password='1234',
# controller=controller,
# output_path='/tmp/ALRL2020/client/user0',
# )