-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpreprocessing_play.py
executable file
·47 lines (31 loc) · 1.05 KB
/
preprocessing_play.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
import argparse
import gym
from gym.utils import play as gym_play
import sys
from os import path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from debug_wrappers import ConcatFrameStack
from preprocessing import generic_preprocess, pong_preprocess
"""
Play a game with preprocessing applied to check that preprocessing is sane.
"""
def callback(prev_obs, obs, action, rew, env_done, info):
print("Step {}: reward {}, done {}".format(callback.step_n, rew, env_done))
callback.step_n += 1
callback.step_n = 0
def main():
parser = argparse.ArgumentParser()
parser.add_argument("env_id")
parser.add_argument("--pong_preprocessing", action="store_true")
args = parser.parse_args()
if args.pong_preprocessing:
wrap_fn = pong_preprocess
else:
wrap_fn = generic_preprocess
env = gym.make(args.env_id)
env = wrap_fn(env, max_n_noops=0)
env = ConcatFrameStack(env)
gym_play.play(env, fps=15, zoom=4, callback=callback)
if __name__ == '__main__':
main()