Args: exp (Experience):
(self, exp)
| 50 | self.writer_lock = threading.Lock() # a lock to guard writing to the memory |
| 51 | |
| 52 | def append(self, exp): |
| 53 | """ |
| 54 | Args: |
| 55 | exp (Experience): |
| 56 | """ |
| 57 | if self._curr_size < self.max_size: |
| 58 | self._assign(self._curr_pos, exp) |
| 59 | self._curr_pos = (self._curr_pos + 1) % self.max_size |
| 60 | self._curr_size += 1 |
| 61 | else: |
| 62 | self._assign(self._curr_pos, exp) |
| 63 | self._curr_pos = (self._curr_pos + 1) % self.max_size |
| 64 | |
| 65 | def sample(self, idx): |
| 66 | """ return a tuple of (s,r,a,o), |