Skip to content

Commit

Permalink
changed visualizer rllib to not open SUMO unnecessarily (#788)
Browse files Browse the repository at this point in the history
* changed visualizer rllib to not open SUMO unnecessarily
  • Loading branch information
ZhongxiaYan authored and eugenevinitsky committed Nov 25, 2019
1 parent 44e21a3 commit 7ff7815
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions flow/visualize/visualizer_rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ def visualizer_rllib(args):
sim_params.render = 'drgb'
sim_params.pxpm = 4
elif args.render_mode == 'sumo_gui':
sim_params.render = True
print('NOTE: With render mode {}, an extra instance of the SUMO GUI '
'will display before the GUI for visualizing the result. Click '
'the green Play arrow to continue.'.format(args.render_mode))
sim_params.render = False # will be set to True below
elif args.render_mode == 'no_render':
sim_params.render = False
if args.save_render:
Expand Down Expand Up @@ -159,6 +156,9 @@ def visualizer_rllib(args):
else:
env = gym.make(env_name)

if args.render_mode == 'sumo_gui':
env.sim_params.render = True # set to True after initializing agent and env

if multiagent:
rets = {}
# map the agent id to its policy
Expand Down Expand Up @@ -186,8 +186,9 @@ def visualizer_rllib(args):
else:
use_lstm = False

env.restart_simulation(
sim_params=sim_params, render=sim_params.render)
# if restart_instance, don't restart here because env.reset will restart later
if not sim_params.restart_instance:
env.restart_simulation(sim_params=sim_params, render=sim_params.render)

# Simulate and collect metrics
final_outflows = []
Expand Down

0 comments on commit 7ff7815

Please sign in to comment.