def create_vncatari_env(env_id, client_id, remotes, **_): """Create an Atari (rescaled) environment by passing environment id. Parameters ---------- env_id : str environment id to be registered in Gym client_id : str Client ID remotes : str BLANK kwargs : dict BLANK """ env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) env = GymCoreAction(env) env = AtariRescale42x42(env) env = EpisodeID(env) env = DiagnosticsInfo(env) env = Unvectorize(env) logger.info('Connecting to remotes: %s', remotes) fps = env.metadata['video.frames_per_second'] env.configure(remotes=remotes, start_timeout=15 * 60, fps=fps, client_id=client_id) return env
def create_flash_env(env_id, client_id, remotes, **_): env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) reg = universe.runtime_spec('flashgames').server_registry height = reg[env_id]["height"] width = reg[env_id]["width"] env = CropScreen(env, height, width, 84, 18) env = FlashRescale(env) keys = ['left', 'right', 'up', 'down', 'x'] env = DiscreteToFixedKeysVNCActions(env, keys) env = EpisodeID(env) env = DiagnosticsInfo(env) env = Unvectorize(env) env.configure(fps=5.0, remotes=remotes, start_timeout=15 * 60, client_id=client_id, vnc_driver='go', vnc_kwargs={ 'encoding': 'tight', 'compress_level': 0, 'fine_quality_level': 50, 'subsample_level': 3 }) return env
def create_vncatari_env(env_id, client_id, remotes, **_): env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) env = GymCoreAction(env) env = AtariRescale42x42(env) #env = NormalizedEnv(env) env = EpisodeID(env) env = DiagnosticsInfo(env) if "multi_obs_settings" in _.keys(): _multi = [env] + list(_["multi_obs_settings"]) env = [env, SplitScreen(*_multi)] #env = Unvectorize(env) logger.info('Connecting to remotes: %s', remotes) fps = env.metadata['video.frames_per_second'] if not "no_config" in _.keys(): env.configure(remotes=remotes, start_timeout=15 * 60, fps=fps, client_id=client_id) return env
def createEnv(env_id, remotes, **_): env = gym.make(env_id) env = Vision(env) # extracts the vision modality and discards all others env = Logger(env) env = CropScreen( env, height=300, width=500, top=84, left=18 ) # Crops out a [height]x[width] area from screen starting from (top,left) env = EpisodeID(env) env.configure(remotes=remotes) return env
def create_slither_env(state_type): env = gym.make('internet.SlitherIO-v0') env = Vision(env) #Because logging is annoying #env = Logger(env) env = BlockingReset(env) env = CropScreen(env, 300, 500, 85, 20) #env = DiscreteToFixedKeysVNCActions(env, ['left', 'right', 'space', 'left space', 'right space']) env = EpisodeID(env) env = RenderWrapper(env, state_type) return env
def create_flash_env(env_id, client_id, remotes, **_): env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) reg = universe.runtime_spec('flashgames').server_registry height = reg[env_id]["height"] width = reg[env_id]["width"] env = CropScreen(env, height, width, 84, 18) env = FlashRescale(env) #env = NormalizedEnv(env) keys = ['left', 'right', 'up', 'down', 'x'] if env_id == 'flashgames.NeonRace-v0': # Better key space for this game. keys = ['left', 'right', 'up', 'left up', 'right up', 'down', 'up x'] if env_id == 'flashgames.LuxUltimate-v0': keys = ['a', 's', 'd'] if env_id == 'flashgames.RetroRunner-v0': keys = ['up', 'right'] if env_id == 'flashgames.RunRamRun-v0-v0': keys = ['up', 'down'] logger.info('create_flash_env(%s): keys=%s', env_id, keys) env = DiscreteToFixedKeysVNCActions(env, keys) env = EpisodeID(env) env = DiagnosticsInfo(env) if "multi_obs_settings" in _.keys(): _multi = [env] + list(_["multi_obs_settings"]) #env = SplitScreen(*_multi) env = SplitScreen(*_multi) #env = Unvectorize(env) if not "no_config" in _.keys(): env.configure(fps=5.0, remotes=remotes, start_timeout=15 * 60, client_id=client_id, vnc_driver='go', vnc_kwargs={ 'encoding': 'tight', 'compress_level': 0, 'fine_quality_level': 50, 'subsample_level': 3 }, replace_on_crash=True) return env
def create_vncatari_env(env_id, client_id, remotes, **_): env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) env = GymCoreAction(env) env = AtariRescale(env) env = EpisodeID(env) env = DiagnosticsInfo(env) env = Unvectorize(env) logger.info('Connecting to remotes: %s', remotes) fps = env.metadata['video.frames_per_second'] env.configure(remotes=remotes, start_timeout=15 * 60, fps=fps, client_id=client_id) return env
def create_flash_env(env_id, client_id, remotes, **_): """ Create a Flash environment by passing environment id. Parameters ---------- env_id : str environment id to be registered in Gym client_id : str Client ID remotes : str BLANK kwargs : dict BLANK """ env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) reg = universe.runtime_spec('flashgames').server_registry height = reg[env_id]["height"] width = reg[env_id]["width"] env = CropScreen(env, height, width, 84, 18) env = FlashRescale(env) keys = ['left', 'right', 'up', 'down', 'x'] if env_id == 'flashgames.NeonRace-v0': # Better key space for this game. keys = ['left', 'right', 'up', 'left up', 'right up', 'down', 'up x'] logger.info('create_flash_env(%s): keys=%s', env_id, keys) env = DiscreteToFixedKeysVNCActions(env, keys) env = EpisodeID(env) env = DiagnosticsInfo(env) env = Unvectorize(env) env.configure(fps=5.0, remotes=remotes, start_timeout=15 * 60, client_id=client_id, vnc_driver='go', vnc_kwargs={ 'encoding': 'tight', 'compress_level': 0, 'fine_quality_level': 50, 'subsample_level': 3 }) return env
def create_miniwob_env(env_id, client_id, remotes, **_): env = gym.make(env_id) env = Vision(env) env = Logger(env) env = BlockingReset(env) env = CropScreen(env, 160, 160, 125, 10) if (env_id == 'wob.mini.NumberCheckboxes-v0') or ( env_id == 'wob.mini.ChaseCircle-v0') or ( env_id == 'wob.mini.BisectAngle-v0') or ( env_id == 'wob.mini.FindMidpoint-v0') or ( env_id == 'wob.mini.CircleCenter-v0'): # These tasks won't need a sharp resolution to perform well; therefore 80x80 pixels should be enough obs_height = 80 obs_width = 80 else: obs_height = 100 obs_width = 100 env = WobRescale(env, obs_height, obs_width) logger.info('create_miniwob_env(%s): ', env_id) noAgent = False # if True; no Agent will perform if env_id == 'wob.mini.NumberCheckboxes-v0': # there are exact 29 possible actions to click at: the 28 checkboxes and 1 for the submit button env = ac_space.SoftmaxClickTask( env, active_region=(10 + 14, 75 + 57, 24 + 55, 132 + 102 + 11 + 22), noclick_regions=[(24 + 11 + 2, 42, 132 + 102 + 9, 28)], discrete_mouse_step=17, noAgent=noAgent) elif (env_id == 'wob.mini.BisectAngle-v0') or ( env_id == 'wob.mini.FindMidpoint-v0') or ( env_id == 'wob.mini.CircleCenter-v0') or ( env_id == 'wob.mini.RightAngle-v0'): env = ac_space.SoftmaxClickTask(env, discrete_mouse_step=8, noAgent=noAgent) elif env_id == 'wob.mini.CopyPaste-v0': # makes use of a special SoftmaxCopyPasteTask class that offers the actions of ctrl+a, ctrl+c, ctrl+v and mouse clicks env = ac_space.SoftmaxCopyPasteTask(env, discrete_mouse_step=20, noAgent=noAgent) elif (env_id == 'wob.mini.SimpleAlgebra-v0') or ( env_id == 'wob.mini.SimpleArithmetic-v0') or ( env_id == 'wob.mini.VisualAddition-v0'): # these tasks make use of the SoftmaxMathTask class which defines special action_space handling env = ac_space.SoftmaxMathTask(env, noAgent=noAgent) elif (env_id == 'wob.mini.DragBox-v0'): # makes use of a special SoftmaxDragTask class that unclicks when clicked and vice versa, the active_region is adapted to the task env = ac_space.SoftmaxDragTask(env, active_region=(10, 75 + 50, 10 + 160, 75 + 50 + 105), discrete_mouse_step=16, noAgent=noAgent) elif (env_id == 'wob.mini.HighlightText-v0'): # makes use of a special SoftmaxDragTask class that unclicks when clicked and vice versa, the active_region is adapted to the task env = ac_space.SoftmaxDragTask(env, active_region=(10, 75 + 50, 10 + 155, 75 + 50 + 50), discrete_mouse_step=16, noAgent=noAgent) elif (env_id == 'wob.mini.TextTransform-v0'): # makes use of all keyboard letters and mouse clicks env = ac_space.SoftmaxFullLettersAndMouse(env, discrete_mouse_step=16, noAgent=noAgent) elif (env_id == 'wob.mini.TicTacToe-v0'): # allows just 9 fields to click in env = ac_space.SoftmaxClickTask(env, discrete_mouse_step=55, noAgent=noAgent) else: # the dimension of the action_space for all other tasks are 20x20 = 400 env = ac_space.SoftmaxClickTask(env, discrete_mouse_step=8, noAgent=noAgent) env = EpisodeID(env) env = DiagnosticsInfo(env) env = Unvectorize(env) if (env_id == 'wob.mini.SimpleAlgebra-v0') or ( env_id == 'wob.mini.SimpleArithmetic-v0') or ( env_id == 'wob.mini.VisualAddition-v0'): # a fps rate above 3.0 on these tasks leads to instability issues due to the asynchronity between the browser inside of the docker image and the agent env.configure(fps=3.0, remotes=remotes, start_timeout=15 * 60, client_id=client_id, vnc_driver='go', vnc_kwargs={ 'encoding': 'tight', 'compress_level': 0, 'fine_quality_level': 100, 'subsample_level': 0 }) else: # all regular tasks perform on 5.0 fps env.configure(fps=5.0, remotes=remotes, start_timeout=15 * 60, client_id=client_id, vnc_driver='go', vnc_kwargs={ 'encoding': 'tight', 'compress_level': 0, 'fine_quality_level': 100, 'subsample_level': 0 }) return env