From 669762a453e4132711ef950751e43d60a0103fef Mon Sep 17 00:00:00 2001 From: romue Date: Fri, 4 Jun 2021 18:13:55 +0200 Subject: [PATCH] added policy_adaption --- .../natural_rl_environment/natural_env.py | 2 +- environments/policy_adaption/test.py | 24 ++----------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/environments/policy_adaption/natural_rl_environment/natural_env.py b/environments/policy_adaption/natural_rl_environment/natural_env.py index b655e8a..6940eef 100755 --- a/environments/policy_adaption/natural_rl_environment/natural_env.py +++ b/environments/policy_adaption/natural_rl_environment/natural_env.py @@ -69,7 +69,7 @@ def make(name='Pong-v0', imgsource='color', files=None): imgsource = RandomColorSource(shape2d) elif imgsource == "noise": imgsource = NoiseSource(shape2d) - if args.imgsource == "images": + elif imgsource == "images": imgsource = RandomImageSource(shape2d, files) else: raise NotImplementedError(f'{imgsource} is not supported, use one of {{video, color, noise}}') diff --git a/environments/policy_adaption/test.py b/environments/policy_adaption/test.py index 5dbd766..1434205 100644 --- a/environments/policy_adaption/test.py +++ b/environments/policy_adaption/test.py @@ -4,25 +4,5 @@ from environments.policy_adaption.natural_rl_environment.imgsource import * from environments.policy_adaption.natural_rl_environment.natural_env import * if __name__ == "__main__": - imgsource = 'video' - env = gym.make('SpaceInvaders-v0') # gravitar, breakout, MsPacman, Space Invaders - shape2d = env.observation_space.shape[:2] - print(shape2d) - - if imgsource == 'video': - imgsource = RandomVideoSource(shape2d, ['/Users/romue/PycharmProjects/EDYS/environments/policy_adaption/natural_rl_environment/videos/stars.mp4']) - elif imgsource == "color": - imgsource = RandomColorSource(shape2d) - elif imgsource == "noise": - imgsource = NoiseSource(shape2d) - wrapped_env = ReplaceBackgroundEnv( - #env, BackgroundMattingWithColor((144, 72, 17)), imgsource - env, BackgroundMattingWithColor((0, 0, 0)), imgsource - ) - env = wrapped_env - - - env.reset() - - state, *_ = env.step(env.action_space.sample()) - play.play(wrapped_env, zoom=4) \ No newline at end of file + env = make('SpaceInvaders-v0', 'color') # gravitar, breakout, MsPacman, Space Invaders + play.play(env, zoom=4) \ No newline at end of file