def finalize_episode(self, update_average_reward=None):
    self.current_episode.summarize()
    if (update_average_reward is not None):
        new_average = self.current_episode.final_stats['online_rewards']
        if (np.abs((new_average - self.initial_reward)) > 0.05):
            self.initial_reward = new_average
            self.average_reward_counter = 0
        self.average_reward = (((self.average_reward_counter * self.average_reward) + new_average) / (self.average_reward_counter + 1))
        self.average_reward_counter += 1
    logger.info(self.current_episode)
    self.write_all()
def finalize_episode(self, update_average_reward=None):
    self.current_episode.summarize()
    if (update_average_reward is not None):
        new_average = self.current_episode.final_stats['online_rewards']
        if (np.abs((new_average - self.initial_reward)) > 0.05):
            self.initial_reward = new_average
            self.average_reward_counter = 0
        self.average_reward = (((self.average_reward_counter * self.average_reward) + new_average) / (self.average_reward_counter + 1))
        self.average_reward_counter += 1
    logger.info(self.current_episode)
    self.write_all()