Skip to content

Instantly share code, notes, and snippets.

@keithmgould
Created April 12, 2018 15:53
Show Gist options
  • Save keithmgould/2e17a44fa253ca294a18f81ccf42468e to your computer and use it in GitHub Desktop.
Save keithmgould/2e17a44fa253ca294a18f81ccf42468e to your computer and use it in GitHub Desktop.
simple method for discounting rewards
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