def exploit(env, sequence):
    """
    Replay an action sequence. Returns the final cumulative reward.
    """
    env.reset()
    done = False
    idx = 0
    while not done:
        env.render()
        if idx >= len(sequence):
            # Force breaking out
            done = True

            # pad with NOPs if needed. This only works for games with time limits (timeouts)
            # _, _, done, _ = env.step(np.zeros((12,), dtype='bool'))
        else:
            _, _, done, _ = env.step(sequence[idx])
        idx += 1
    return env.total_reward