-
-
Save keithmgould/2e17a44fa253ca294a18f81ccf42468e to your computer and use it in GitHub Desktop.
simple method for discounting rewards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def discount_rewards(self, rewards): | |
discounted_rewards = np.zeros_like(rewards) | |
running_add = 0 | |
for t in reversed(range(0, len(rewards))): | |
running_add = running_add * 0.99 + rewards[t] | |
discounted_rewards[t] = running_add | |
return discounted_rewards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment