Choose action :param s: state :param greedy: get action greedy or not :return: act
(self, s, greedy=False)
| 149 | i.assign(self.ema.average(j)) |
| 150 | |
| 151 | def get_action(self, s, greedy=False): |
| 152 | """ |
| 153 | Choose action |
| 154 | :param s: state |
| 155 | :param greedy: get action greedy or not |
| 156 | :return: act |
| 157 | """ |
| 158 | a = self.actor(np.array([s], dtype=np.float32))[0] |
| 159 | if greedy: |
| 160 | return a |
| 161 | return np.clip( |
| 162 | np.random.normal(a, self.var), -self.action_range, self.action_range |
| 163 | ) # add randomness to action selection for exploration |
| 164 | |
| 165 | def learn(self): |
| 166 | """ |