(self, state, action, reward, next_state, done)
| 95 | self.position = 0 |
| 96 | |
| 97 | def push(self, state, action, reward, next_state, done): |
| 98 | if len(self.buffer) < self.capacity: |
| 99 | self.buffer.append(None) |
| 100 | self.buffer[self.position] = (state, action, reward, next_state, done) |
| 101 | self.position = int((self.position + 1) % self.capacity) # as a ring buffer |
| 102 | |
| 103 | def sample(self, BATCH_SIZE): |
| 104 | batch = random.sample(self.buffer, BATCH_SIZE) |