コード例 #1
0
ファイル: envs.py プロジェクト: ankor-ai/RL_Projects
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']
    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
コード例 #2
0
ファイル: envs.py プロジェクト: ankor-ai/RL_Projects
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 = 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
コード例 #3
0
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 = 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
コード例 #4
0
ファイル: envs.py プロジェクト: Wellan89/RL_Agent
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
コード例 #5
0
def create_flash_env(env_id, client_id, remotes, **_):
    #environment wrappers
    env = gym.make(env_id)
    env = Vision(env)
    env = Logger(env)
    env = BlockingReset(env)

    reg = universe.runtime_spec('flashgames').server_registry
    #environment resizing
    height = reg[env_id]["height"]
    width = reg[env_id]["width"]
    env = CropScreen(env, height, width, 84, 18)
    env = FlashRescale(env)

    #define action space
    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
コード例 #6
0
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