def main_loop(self):
        """
            One loop of agent, runs one episode of the environment
        """
        env = self.env
        self.pre_episode()
        obs, info = env.reset()
        total_reward = 0.0
        while True:
            if self.render:
                env.unwrapped.render() # TODO: figure out why it needs to be unwrapped
            self.pre_action(obs)
            action = self.act(obs)
            obs_next, reward, done, info = env.step(action)
            total_reward += reward
            self.post_action(obs, action, obs_next, reward, done, info)
            obs = obs_next
            if done:
                break
        self.post_episode()

        if self.agent_mode in ['eval_deterministic_local', 'eval_stochastic_local']:
            return

        if self.current_episode % 20 == 0:
            self.log.info('Episode {} reward {}'
                          .format(self.current_episode,
                                  total_reward))

            One loop of agent, runs one episode of the environment
        
surreal/agent/base.py