-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
33 lines (26 loc) · 846 Bytes
/
test.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
import gym
import pickle
import pkg_resources
from tdw_transport_challenge.h_agent import H_agent
from agent import init_logs
# Create gym environment and load first training scene
env = gym.make("transport_challenge-v0", train=0, physics=True, port=1071, launch_build=False)
# Reset environment and change to next training scene
env.reset()
# Load Testing scenes
with open(pkg_resources.resource_filename("tdw_transport_challenge", "test_env.pkl"), "rb") as fp:
dataset = pickle.load(fp)
# scene_number is from 0 - 4
scene_number = 0
obs, info = env.reset(scene_info=dataset[scene_number])
# create logger
logger = init_logs()
# Instantiate baseline agent
agent = H_agent(logger=logger)
agent.reset()
while True:
action = agent.act(obs, info)
obs, rewards, done, info = env.step(action)
if done:
break
env.close()