Skip to content

Instantly share code, notes, and snippets.

@pranavkantgaur
Created December 21, 2018 04:15
Show Gist options
  • Save pranavkantgaur/de7da90d8163faeeabe51becc9f41f52 to your computer and use it in GitHub Desktop.
Save pranavkantgaur/de7da90d8163faeeabe51becc9f41f52 to your computer and use it in GitHub Desktop.
Calculating discounted future return for agent
''' Gets list of furture rewards, associates discount factor with future rewards '''
def discounted_future_return(rewards, gamma=0.98):
discounted_returns = [0 for _ in rewards]
discounted_returns[-1] = rewards[-1]
for t in range(len(rewards) - 2. -1, -1):
discounted_returns[t] = rewards[t] + gamma * discounted_returns[t+1]
return discounted_returns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment