Skip to content

Instantly share code, notes, and snippets.

@Danaze
Created August 25, 2020 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danaze/a772c36246d410a11331d56901597c63 to your computer and use it in GitHub Desktop.
Save Danaze/a772c36246d410a11331d56901597c63 to your computer and use it in GitHub Desktop.
def discretize_state(self, obs):
discretized = list()
for i in range(len(obs)):
scaling = (obs[i] + abs(self.lower_bounds[i])) / (self.upper_bounds[i] - self.lower_bounds[i])
new_obs = int(round((self.buckets[i] - 1) * scaling))
new_obs = min(self.buckets[i] - 1, max(0, new_obs))
discretized.append(new_obs)
return tuple(discretized)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment