Args: action: An integer-encoded action frame: One grayscale frame of the game reward: reward the agend received for performing an action terminal: A bool stating whether the episode terminated
(self, action, frame, reward, terminal)
| 97 | self.indices = np.empty(self.batch_size, dtype=np.int32) |
| 98 | |
| 99 | def add_experience(self, action, frame, reward, terminal): |
| 100 | """ |
| 101 | Args: |
| 102 | action: An integer-encoded action |
| 103 | frame: One grayscale frame of the game |
| 104 | reward: reward the agend received for performing an action |
| 105 | terminal: A bool stating whether the episode terminated |
| 106 | """ |
| 107 | if frame.shape != (self.frame_height, self.frame_width): |
| 108 | raise ValueError('Dimension of frame is wrong!') |
| 109 | self.actions[self.current] = action |
| 110 | self.frames[self.current, ...] = frame |
| 111 | self.rewards[self.current] = reward |
| 112 | self.terminal_flags[self.current] = terminal |
| 113 | self.count = max(self.count, self.current+1) |
| 114 | self.current = (self.current + 1) % self.size |
| 115 | |
| 116 | def _get_state(self, index): |
| 117 | if self.count is 0: |