'Add a time step record.
Arguments:
observation -- current or observation
action -- action chosen by the agent
reward -- reward received after taking the action
terminal -- boolean indicating whether the episode ended after this
time step'

def add_sample(self, observation, action, reward, terminal, extra=None):

    self.observations[self.top] = observation
    self.actions[self.top] = action
    self.rewards[self.top] = reward
    self.terminals[self.top] = terminal
    if (extra is not None):
        if (self.extras is None):
            assert (self.size == 0), 'extra    must    be    consistent'
            self.extras = np.zeros(((self.max_steps,) + extra.shape), dtype=extra.dtype)
        self.extras[self.top] = extra
    else:
        assert (self.extras is None)
    if (self.size == self.max_steps):
        self.bottom = ((self.bottom + 1) % self.max_steps)
    else:
        self.size += 1
    self.top = ((self.top + 1) % self.max_steps)
