def rollout(env, agent, max_episode_steps):
 ob = env.reset()
 data = collections.defaultdict(list)
 for _ in xrange(max_episode_steps):
  data['observation'].append(ob)
  action = agent.act(ob)
  data['action'].append(action)
  (ob, rew, done, _) = env.step(action)
  data['reward'].append(rew)
  if done:
   break
 return data

def rollout ( env , agent , max_episode_steps ) : ob = env . reset ( ) data = collections . defaultdict ( list ) for _ in xrange ( max_episode_steps ) : data [ 'observation' ] . append ( ob ) action = agent . act ( ob ) data [ 'action' ] . append ( action ) ( ob , rew , done , _ ) = env . step ( action ) data [ 'reward' ] . append ( rew ) if done : break return data
simulate the env and agent for max_episode_steps .