forked from huawei-noah/SMARTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
egoless.py
42 lines (30 loc) · 967 Bytes
/
egoless.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
import logging
import gym
from examples.argument_parser import default_argument_parser
from smarts.core.utils.episodes import episodes
logging.basicConfig(level=logging.INFO)
def main(scenarios, headless, num_episodes, max_episode_steps=None):
env = gym.make(
"smarts.env:hiway-v0",
scenarios=scenarios,
agent_specs={},
headless=headless,
sumo_headless=True,
)
if max_episode_steps is None:
max_episode_steps = 1000
for episode in episodes(n=num_episodes):
env.reset()
episode.record_scenario(env.scenario_log)
for _ in range(max_episode_steps):
env.step({})
episode.record_step({}, {}, {}, {})
env.close()
if __name__ == "__main__":
parser = default_argument_parser("egoless-example")
args = parser.parse_args()
main(
scenarios=args.scenarios,
headless=args.headless,
num_episodes=args.episodes,
)