import tqdm


def run_simulation(env, agent, metrics, num_steps):
  """Runs a single simulation and returns metrics."""
  observation = env.reset()
  done = False

  for _ in tqdm.trange(num_steps):
    action = agent.act(observation, done)
    observation, _, done, _ = env.step(action)
    if done:
      break

  return {name: metric.measure(env) for name, metric in metrics.items()}