Created
August 8, 2019 09:26
-
-
Save Guitaricet/ca99dd4dd2266b9443563eb7718d58b7 to your computer and use it in GitHub Desktop.
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
def evaluate(env, policy, n_games=1): | |
"""Plays an entire game start to end, returns session rewards.""" | |
game_rewards = [] | |
for _ in range(n_games): | |
# initial observation and memory | |
observation = env.reset() | |
total_reward = 0 | |
for step in range(int(1e6)): | |
res = policy.act(observation, training=False) | |
action = res['actions'] | |
observation, reward, done, info = env.step(action) | |
total_reward += reward | |
if done: | |
break | |
else: | |
print('Very long eposode!') | |
game_rewards.append(total_reward) | |
return game_rewards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment