| 28 | |
| 29 | |
| 30 | def main(): |
| 31 | env_id = get_args().env |
| 32 | env = make_atari(env_id) |
| 33 | env = wrap_deepmind(env, frame_stack=True, clip_rewards=False, episode_life=True) |
| 34 | env = Monitor(env) |
| 35 | # rewards will appear higher than during training since rewards are not clipped |
| 36 | |
| 37 | agent = get_agent(env) |
| 38 | |
| 39 | # check for save path |
| 40 | save_path = os.path.join('models', env_id + '.save') |
| 41 | agent.load(save_path) |
| 42 | |
| 43 | obs = env.reset() |
| 44 | renders = [] |
| 45 | while True: |
| 46 | obs = np.expand_dims(obs.__array__(), axis=0) |
| 47 | a, v = agent.step(obs) |
| 48 | obs, reward, done, info = env.step(a) |
| 49 | env.render() |
| 50 | if done: |
| 51 | print(info) |
| 52 | env.reset() |
| 53 | |
| 54 | |
| 55 | if __name__ == '__main__': |