-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (20 loc) · 715 Bytes
/
test.py
File metadata and controls
28 lines (20 loc) · 715 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 gym_torcs as gymt
import numpy as np
from my_agent.ddpg import Ddpg
from my_agent.ActorNetwork import ActorNetwork
from my_agent.CriticNetwork import CriticNetwork
import torch
env = gymt.TorcsEnv(path="/usr/local/share/games/torcs/config/raceman/quickrace.xml")
insize = env.observation_space.shape[0]
outsize = env.action_space.shape[0]
valuenet = CriticNetwork(insize, outsize)
policynet = ActorNetwork(insize)
agent = Ddpg(valuenet, policynet, buffersize=1)
agent.load_state_dict(torch.load('best_agent'))
#agent.to(device)
obs, reward, done, info = env.reset(relaunch=True, render=True)
while True:
obs, reward, done, info = env.step()
if (done):
print("DONE")
break