added policy_adaption

This commit is contained in:
romue
2021-06-04 18:13:55 +02:00
parent b70b12edda
commit 669762a453
2 changed files with 3 additions and 23 deletions

View File

@ -69,7 +69,7 @@ def make(name='Pong-v0', imgsource='color', files=None):
imgsource = RandomColorSource(shape2d) imgsource = RandomColorSource(shape2d)
elif imgsource == "noise": elif imgsource == "noise":
imgsource = NoiseSource(shape2d) imgsource = NoiseSource(shape2d)
if args.imgsource == "images": elif imgsource == "images":
imgsource = RandomImageSource(shape2d, files) imgsource = RandomImageSource(shape2d, files)
else: else:
raise NotImplementedError(f'{imgsource} is not supported, use one of {{video, color, noise}}') raise NotImplementedError(f'{imgsource} is not supported, use one of {{video, color, noise}}')

View File

@ -4,25 +4,5 @@ from environments.policy_adaption.natural_rl_environment.imgsource import *
from environments.policy_adaption.natural_rl_environment.natural_env import * from environments.policy_adaption.natural_rl_environment.natural_env import *
if __name__ == "__main__": if __name__ == "__main__":
imgsource = 'video' env = make('SpaceInvaders-v0', 'color') # gravitar, breakout, MsPacman, Space Invaders
env = gym.make('SpaceInvaders-v0') # gravitar, breakout, MsPacman, Space Invaders play.play(env, zoom=4)
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)