def _add_to_replay_buffer(self, sample_buffer):
        """add samples in sample_buffer to replay buffer"""
        n = 0
        for episode in sample_buffer.episodes():
            v, f, a, r = episode.views, episode.features, episode.actions, episode.rewards

            m = len(r)

            mask = np.ones((m,))
            terminal = np.zeros((m,), dtype=np.bool)
            if episode.terminal:
                terminal[-1] = True
            else:
                mask[-1] = 0

            item = [v, f, a, r, terminal, mask, m]
            self.replay_buffer_lens.append(m)
            self.replay_buffer.append(item)

            n += m
        return n
add samples in sample_buffer to replay buffer
python/magent/builtin/tf_model/drqn.py