Skip to content

Instantly share code, notes, and snippets.

@Guitaricet
Created August 8, 2019 09:26
Show Gist options
  • Save Guitaricet/ca99dd4dd2266b9443563eb7718d58b7 to your computer and use it in GitHub Desktop.
Save Guitaricet/ca99dd4dd2266b9443563eb7718d58b7 to your computer and use it in GitHub Desktop.
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