forked from Atcold/pytorch-PPUU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
play_maps.py
79 lines (65 loc) · 1.9 KB
/
play_maps.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 argparse
import numpy
import gym
parser = argparse.ArgumentParser()
parser.add_argument('-nb_conditions', type=int, default=10)
parser.add_argument('-display', type=int, default=1)
parser.add_argument('-map', type=str, default='i80', choices={'ai', 'i80', 'us101', 'lanker', 'peach'})
parser.add_argument('-state_image', type=int, default=0)
parser.add_argument('-store', type=int, default=0)
parser.add_argument('-nb_episodes', type=int, default=1)
parser.add_argument('-fps', type=int, default=1e3)
parser.add_argument('-delta_t', type=float, default=0.1)
opt = parser.parse_args()
kwargs = {
'fps': opt.fps,
'nb_states': opt.nb_conditions,
'display': opt.display,
'state_image': opt.state_image,
'store': opt.store,
'delta_t': opt.delta_t,
}
gym.envs.registration.register(
id='Traffic-v0',
entry_point='traffic_gym:Simulator',
kwargs=kwargs
)
gym.envs.registration.register(
id='I-80-v0',
entry_point='map_i80:I80',
kwargs=kwargs,
)
gym.envs.registration.register(
id='US-101-v0',
entry_point='map_us101:US101',
kwargs=kwargs,
)
gym.envs.registration.register(
id='Lankershim-v0',
entry_point='map_lanker:Lankershim',
kwargs=kwargs,
)
gym.envs.registration.register(
id='Peachtree-v0',
entry_point='map_peach:Peachtree',
kwargs=kwargs,
)
env_names = {
'ai': 'Traffic-v0',
'i80': 'I-80-v0',
'us101': 'US-101-v0',
'lanker': 'Lankershim-v0',
'peach': 'Peachtree-v0',
}
print('Building the environment (loading data, if any)')
env = gym.make(env_names[opt.map])
for episode in range(opt.nb_episodes):
# env.reset(frame=int(input('Frame: ')), time_slot=0)
env.reset(frame=0, time_slot=0)
done = False
while not done:
observation, reward, done, info = env.step(numpy.zeros((2,)))
# print(observation, reward, done, info)
env.render()
print('Episode completed!')
print('Done')