episode_count = -1 #forever while True: #if episode is done if done: episode_count += 1 logging.info("Episode: %i", episode_count) #reset env state_np = env.reset() #set render flag based on time render = (time.time() - last_render_time) > 5 #Get an action from our agent action = agent.get_action(state_np) #take a step in the environment new_state_np, reward, done, info_dict = env.step(action) #let the agent record the experience agent.record_experience(state_np, action, reward, done) #update the state state_np = new_state_np #if render is set then render this episode if render: env.render() #update the time so that its not rendered for a while last_render_time = time.time()