Created
December 21, 2018 04:15
-
-
Save pranavkantgaur/de7da90d8163faeeabe51becc9f41f52 to your computer and use it in GitHub Desktop.
Calculating discounted future return for agent
This file contains hidden or 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
''' 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