当前位置: 首页>>代码示例>>Python>>正文


Python doom_py.DoomGame类代码示例

本文整理汇总了Python中doom_py.DoomGame的典型用法代码示例。如果您正苦于以下问题:Python DoomGame类的具体用法?Python DoomGame怎么用?Python DoomGame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DoomGame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self):
     super(DoomDefendLineEnv, self).__init__()
     package_directory = os.path.dirname(os.path.abspath(__file__))
     self.loader = Loader()
     self.game = DoomGame()
     self.game.load_config(os.path.join(package_directory, 'assets/defend_the_line.cfg'))
     self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
     self.game.set_doom_game_path(self.loader.get_freedoom_path())
     self.game.set_doom_scenario_path(self.loader.get_scenario_path('defend_the_line.wad'))
     self.screen_height = 480                    # Must match .cfg file
     self.screen_width = 640                     # Must match .cfg file
     self.game.set_window_visible(False)
     self.viewer = None
     self._seed()
     self.game.init()
     self.game.new_episode()
开发者ID:cdingding,项目名称:gym,代码行数:16,代码来源:doom_defend_line.py

示例2: __init__

 def __init__(self, level):
     utils.EzPickle.__init__(self)
     self.previous_level = -1
     self.level = level
     self.game = DoomGame()
     self.loader = Loader()
     self.doom_dir = os.path.dirname(os.path.abspath(__file__))
     self.mode = 'fast'                          # 'human', 'fast' or 'normal'
     self.no_render = False                      # To disable double rendering in human mode
     self.viewer = None
     self.is_initialized = False                 # Indicates that reset() has been called
     self.curr_seed = 0
     self.action_space = spaces.HighLow(
         np.matrix([[0, 1, 0]] * 38 + [[-10, 10, 0]] * 2 + [[-100, 100, 0]] * 3, dtype=np.int8))
     self.allowed_actions = list(range(NUM_ACTIONS))
     self._configure()
开发者ID:SCSCML,项目名称:gym,代码行数:16,代码来源:doom_env.py

示例3: __init__

 def __init__(self):
     package_directory = os.path.dirname(os.path.abspath(__file__))
     self.loader = Loader()
     self.game = DoomGame()
     self.game.load_config(os.path.join(package_directory, 'assets/my_way_home.cfg'))
     self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
     self.game.set_doom_game_path(self.loader.get_freedoom_path())
     self.game.set_doom_scenario_path(self.loader.get_scenario_path('my_way_home.wad'))
     self.screen_height = 480                    # Must match .cfg file
     self.screen_width = 640                     # Must match .cfg file
     # 3 allowed actions [12, 13, 14] (must match .cfg file)
     self.action_space = doom_spaces.HighLow(np.matrix([[0, 1, 0]] * 3))
     self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
     self.game.set_window_visible(False)
     self.viewer = None
     self.game.init()
     self.game.new_episode()
开发者ID:paulhendricks,项目名称:gym-doom,代码行数:17,代码来源:doom_my_way_home.py

示例4: __init__

    def __init__(self):
        package_directory = os.path.dirname(os.path.abspath(__file__))
        self.loader = Loader()
        self.game = DoomGame()
        self.game.load_config(os.path.join(package_directory, 'assets/predict_position.cfg'))
        self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
        self.game.set_doom_game_path(self.loader.get_freedoom_path())
        self.game.set_doom_scenario_path(self.loader.get_scenario_path('predict_position.wad'))
        self.game.set_doom_map('map01')
        self.screen_height = 480                    # Must match .cfg file
        self.screen_width = 640                     # Must match .cfg file
        self.game.set_window_visible(False)
        self.viewer = None
        self.game.init()
        self.game.new_episode()

        self._seed()
开发者ID:cdingding,项目名称:gym,代码行数:17,代码来源:doom_predict_position.py

示例5: __init__

 def __init__(self):
     super(DoomCorridorEnv, self).__init__()
     package_directory = os.path.dirname(os.path.abspath(__file__))
     self.loader = Loader()
     self.game = DoomGame()
     self.game.load_config(os.path.join(package_directory, 'assets/deadly_corridor.cfg'))
     self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
     self.game.set_doom_game_path(self.loader.get_freedoom_path())
     self.game.set_doom_scenario_path(self.loader.get_scenario_path('deadly_corridor.wad'))
     self.screen_height = 480                    # Must match .cfg file
     self.screen_width = 640                     # Must match .cfg file
     # action indexes are [0, 9, 10, 12, 13, 14]
     self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 6))
     self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
     self.game.set_window_visible(False)
     self.viewer = None
     self.game.init()
     self.game.new_episode()
开发者ID:Eulerianial,项目名称:gym,代码行数:18,代码来源:doom_corridor.py

示例6: _load_level

    def _load_level(self):
        # Closing if is_initialized
        if self.is_initialized:
            self.is_initialized = False
            self.game.close()
            self.game = DoomGame()

        # Loading Paths
        if not self.is_initialized:
            self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
            self.game.set_doom_game_path(self.loader.get_freedoom_path())

        # Common settings
        self._closed = False
        self.game.load_config(os.path.join(self.doom_dir, 'assets/%s' % DOOM_SETTINGS[self.level][CONFIG]))
        self.game.set_doom_scenario_path(self.loader.get_scenario_path(DOOM_SETTINGS[self.level][SCENARIO]))
        if DOOM_SETTINGS[self.level][MAP] != '':
            self.game.set_doom_map(DOOM_SETTINGS[self.level][MAP])
        self.game.set_doom_skill(DOOM_SETTINGS[self.level][DIFFICULTY])
        self.previous_level = self.level
        self.allowed_actions = DOOM_SETTINGS[self.level][ACTIONS]
        self.game.set_screen_resolution(self.screen_resolution)

        # Algo mode
        if 'human' != self.mode:
            self.game.set_window_visible(False)
            self.game.set_mode(Mode.PLAYER)
            self.no_render = False
            self.game.init()
            self._start_episode()
            self.is_initialized = True
            return self.game.get_state().image_buffer.copy()

        # Human mode
        else:
            self.game.add_game_args('+freelook 1')
            self.game.set_window_visible(True)
            self.game.set_mode(Mode.SPECTATOR)
            self.no_render = True
            self.game.init()
            self._start_episode()
            self.is_initialized = True
            self._play_human_mode()
            return np.zeros(shape=self.observation_space.shape, dtype=np.uint8)
开发者ID:LucasvBerkel,项目名称:TweedejaarsProject,代码行数:44,代码来源:doom_env.py

示例7: __init__

 def __init__(self):
     super(DoomTakeCoverEnv, self).__init__()
     package_directory = os.path.dirname(os.path.abspath(__file__))
     self.loader = Loader()
     self.game = DoomGame()
     self.game.load_config(os.path.join(package_directory, 'assets/take_cover.cfg'))
     self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
     self.game.set_doom_game_path(self.loader.get_freedoom_path())
     self.game.set_doom_scenario_path(self.loader.get_scenario_path('take_cover.wad'))
     self.game.set_doom_map('map01')
     self.screen_height = 480                    # Must match .cfg file
     self.screen_width = 640                     # Must match .cfg file
     # 2 allowed actions [9, 10] (must match .cfg file)
     self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 2))
     self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
     self.game.set_window_visible(False)
     self.viewer = None
     self.game.init()
     self.game.new_episode()
开发者ID:Eulerianial,项目名称:gym,代码行数:19,代码来源:doom_take_cover.py

示例8: __init__

 def __init__(self, level):
     utils.EzPickle.__init__(self)
     self.previous_level = -1
     self.level = level
     self.game = DoomGame()
     self.loader = Loader()
     self.doom_dir = os.path.dirname(os.path.abspath(__file__))
     self.mode = 'fast'                          # 'human', 'fast' or 'normal'
     self.no_render = False                      # To disable double rendering in human mode
     self.viewer = None
     self.is_initialized = False                 # Indicates that reset() has been called
     self.find_new_level = False                 # Indicates that we need a level change
     self.curr_seed  = 0
     self.screen_height = 480
     self.screen_width = 640
     self.action_space = spaces.HighLow(
         np.matrix([[0, 1, 0]] * 38 + [[-10, 10, 0]] * 2 + [[-100, 100, 0]] * 3, dtype=np.int8))
     self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
     self.allowed_actions = list(range(NUM_ACTIONS))
开发者ID:JKCooper2,项目名称:gym,代码行数:19,代码来源:doom_env.py

示例9: __init__

 def __init__(self, level):
     self.previous_level = -1
     self.level = level
     self.game = DoomGame()
     self.loader = Loader()
     self.doom_dir = os.path.dirname(os.path.abspath(__file__))
     self._mode = 'algo'                         # 'algo' or 'human'
     self.no_render = False                      # To disable double rendering in human mode
     self.viewer = None
     self.is_initialized = False                 # Indicates that reset() has been called
     self.curr_seed = 0
     self.lock = (DoomLock()).get_lock()
     self.action_space = spaces.MultiDiscrete([[0, 1]] * 38 + [[-10, 10]] * 2 + [[-100, 100]] * 3)
     self.allowed_actions = list(range(NUM_ACTIONS))
     self.screen_height = 480
     self.screen_width = 640
     self.screen_resolution = ScreenResolution.RES_640X480
     self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
     self._seed()
     self._configure()
开发者ID:shanlior,项目名称:gym-doom,代码行数:20,代码来源:doom_env.py

示例10: DoomDefendCenterEnv

class DoomDefendCenterEnv(doom_env.DoomEnv):
    """
    ------------ Training Mission 3 - Defend the Center ------------
    This map is designed to teach you how to kill and how to stay alive.
    You will also need to keep an eye on your ammunition level. You are only
    rewarded for kills, so figure out how to stay alive.

    The map is a circle with monsters in the middle. Monsters will
    respawn with additional health when killed. Kill as many as you can
    before you run out of ammo.

    Allowed actions:
        [0]  - ATTACK                           - Shoot weapon - Values 0 or 1
        [13] - TURN_RIGHT                       - Turn right - Values 0 or 1
        [14] - TURN_LEFT                        - Turn left - Values 0 or 1
    Note: see controls.md for details

    Rewards:
        +  1    - Killing the monster
        -  1    - Penalty for being killed

    Goal: 10 points
        Kill 10 monsters (you have 26 ammo)

    Ends when:
        - Player is dead
        - Timeout (60 seconds - 2100 frames)
    -----------------------------------------------------
    """
    def __init__(self):
        super(DoomDefendCenterEnv, self).__init__()
        package_directory = os.path.dirname(os.path.abspath(__file__))
        self.loader = Loader()
        self.game = DoomGame()
        self.game.load_config(os.path.join(package_directory, 'assets/defend_the_center.cfg'))
        self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
        self.game.set_doom_game_path(self.loader.get_freedoom_path())
        self.game.set_doom_scenario_path(self.loader.get_scenario_path('defend_the_center.wad'))
        self.screen_height = 480                    # Must match .cfg file
        self.screen_width = 640                     # Must match .cfg file
        self.game.set_window_visible(False)
        self.viewer = None
        self.game.init()
        self.game.new_episode()

        # 3 allowed actions [0, 13, 14] (must match .cfg file)
        self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 3))
        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))

        self._seed()

    def _seed(self, seed=None):
        seed = seeding.hash_seed(seed) % 2**32
        self.game.set_seed(seed)
        return [seed]
开发者ID:DaedalusX,项目名称:gym,代码行数:55,代码来源:doom_defend_center.py

示例11: DoomDeathmatchEnv

class DoomDeathmatchEnv(doom_env.DoomEnv):
    """
    ------------ Final Mission - Deathmatch ------------
    Kill as many monsters as possible without being killed.

    Allowed actions:
        ALL
    Note: see controls.md for details

    Rewards:
        +1      - Killing a monster

    Goal: 25 points
        Kill 25 monsters without being killed

    Ends when:
        - Player is dead
        - Timeout (3 minutes - 6,300 frames)
    -----------------------------------------------------
    """
    def __init__(self):
        super(DoomDeathmatchEnv, self).__init__()
        package_directory = os.path.dirname(os.path.abspath(__file__))
        self.loader = Loader()
        self.game = DoomGame()
        self.game.load_config(os.path.join(package_directory, 'assets/deathmatch.cfg'))
        self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
        self.game.set_doom_game_path(self.loader.get_freedoom_path())
        self.game.set_doom_scenario_path(self.loader.get_scenario_path('deathmatch.wad'))
        self.screen_height = 480                    # Must match .cfg file
        self.screen_width = 640                     # Must match .cfg file
        # 41 allowed actions (must match .cfg file)
        self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 37 + [[0, 10, 0]] * 5))
        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
        self.game.set_window_visible(False)
        self.viewer = None
        self.game.init()
        self.game.new_episode()
开发者ID:GregTarr,项目名称:gym,代码行数:38,代码来源:doom_deathmatch.py

示例12: DoomDefendLineEnv

class DoomDefendLineEnv(doom_env.DoomEnv):
    """
    ------------ Training Mission 4 - Defend the Line ------------
    This map is designed to teach you how to kill and how to stay alive.
    Your ammo will automatically replenish. You are only rewarded for kills,
    so figure out how to stay alive.

    The map is a rectangle with monsters in the middle. Monsters will
    respawn with additional health when killed. Kill as many as you can
    before they kill you. This map is harder than the previous.

    Allowed actions:
        [0]  - ATTACK                           - Shoot weapon - Values 0 or 1
        [13] - TURN_RIGHT                       - Turn right - Values 0 or 1
        [14] - TURN_LEFT                        - Turn left - Values 0 or 1
    Note: see controls.md for details

    Rewards:
        +  1    - Killing the monster
        -  1    - Penalty for being killed

    Goal: 25 points
        Kill 25 monsters

    Ends when:
        - Player is dead
        - Timeout (60 seconds - 2100 frames)
    -----------------------------------------------------
    """
    def __init__(self):
        super(DoomDefendLineEnv, self).__init__()
        package_directory = os.path.dirname(os.path.abspath(__file__))
        self.loader = Loader()
        self.game = DoomGame()
        self.game.load_config(os.path.join(package_directory, 'assets/defend_the_line.cfg'))
        self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
        self.game.set_doom_game_path(self.loader.get_freedoom_path())
        self.game.set_doom_scenario_path(self.loader.get_scenario_path('defend_the_line.wad'))
        self.screen_height = 480                    # Must match .cfg file
        self.screen_width = 640                     # Must match .cfg file
        # 3 allowed actions [0, 13, 14] (must match .cfg file)
        self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 3))
        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
        self.game.set_window_visible(False)
        self.viewer = None
        self.game.init()
        self.game.new_episode()
开发者ID:Eulerianial,项目名称:gym,代码行数:47,代码来源:doom_defend_line.py

示例13: DoomEnv

class DoomEnv(gym.Env, utils.EzPickle):
    metadata = {'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': 35}

    def __init__(self, level):
        utils.EzPickle.__init__(self)
        self.previous_level = -1
        self.level = level
        self.game = DoomGame()
        self.loader = Loader()
        self.doom_dir = os.path.dirname(os.path.abspath(__file__))
        self.mode = 'fast'                          # 'human', 'fast' or 'normal'
        self.no_render = False                      # To disable double rendering in human mode
        self.viewer = None
        self.is_initialized = False                 # Indicates that reset() has been called
        self.curr_seed = 0
        self.action_space = spaces.HighLow(
            np.matrix([[0, 1, 0]] * 38 + [[-10, 10, 0]] * 2 + [[-100, 100, 0]] * 3, dtype=np.int8))
        self.allowed_actions = list(range(NUM_ACTIONS))
        self._seed()
        self._configure()

    def _configure(self, screen_resolution=ScreenResolution.RES_640X480):
        # Often agents end up downsampling the observations. Configuring Doom to
        # return a smaller image yields significant (~10x) speedups
        if screen_resolution == ScreenResolution.RES_640X480:
            self.screen_height = 480
            self.screen_width = 640
            self.screen_resolution = ScreenResolution.RES_640X480
        elif screen_resolution == ScreenResolution.RES_160X120:
            self.screen_height = 120
            self.screen_width = 160
            self.screen_resolution = ScreenResolution.RES_160X120

        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))

    def _load_level(self):
        # Closing if is_initialized
        if self.is_initialized:
            self.is_initialized = False
            self.game.close()
            self.game = DoomGame()

        # Loading Paths
        if not self.is_initialized:
            self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
            self.game.set_doom_game_path(self.loader.get_freedoom_path())

        # Common settings
        self._closed = False
        self.game.load_config(os.path.join(self.doom_dir, 'assets/%s' % DOOM_SETTINGS[self.level][CONFIG]))
        self.game.set_doom_scenario_path(self.loader.get_scenario_path(DOOM_SETTINGS[self.level][SCENARIO]))
        if DOOM_SETTINGS[self.level][MAP] != '':
            self.game.set_doom_map(DOOM_SETTINGS[self.level][MAP])
        self.game.set_doom_skill(DOOM_SETTINGS[self.level][DIFFICULTY])
        self.previous_level = self.level
        self.allowed_actions = DOOM_SETTINGS[self.level][ACTIONS]
        self.game.set_screen_resolution(self.screen_resolution)

        # Algo mode
        if 'human' != self.mode:
            self.game.set_window_visible(False)
            self.game.set_mode(Mode.PLAYER)
            self.no_render = False
            self.game.init()
            self._start_episode()
            self.is_initialized = True
            return self.game.get_state().image_buffer.copy()

        # Human mode
        else:
            self.game.add_game_args('+freelook 1')
            self.game.set_window_visible(True)
            self.game.set_mode(Mode.SPECTATOR)
            self.no_render = True
            self.game.init()
            self._start_episode()
            self.is_initialized = True
            self._play_human_mode()
            return np.zeros(shape=self.observation_space.shape, dtype=np.uint8)

    def _start_episode(self):
        if self.curr_seed > 0:
            self.game.set_seed(self.curr_seed)
            self.curr_seed = 0
        self.game.new_episode()
        return

    def _play_human_mode(self):
        while not self.game.is_episode_finished():
            self.game.advance_action()
            state = self.game.get_state()
            total_reward = self.game.get_total_reward()
            info = self._get_game_variables(state.game_variables)
            info["TOTAL_REWARD"] = round(total_reward, 4)
            print('===============================')
            print('State: #' + str(state.number))
            print('Action: \t' + str(self.game.get_last_action()) + '\t (=> only allowed actions)')
            print('Reward: \t' + str(self.game.get_last_reward()))
            print('Total Reward: \t' + str(total_reward))
            print('Variables: \n' + str(info))
#.........这里部分代码省略.........
开发者ID:LucasvBerkel,项目名称:TweedejaarsProject,代码行数:101,代码来源:doom_env.py

示例14: DoomEnv

class DoomEnv(gym.Env):
    metadata = {'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': 35}

    def __init__(self, level):
        self.previous_level = -1
        self.level = level
        self.game = DoomGame()
        self.loader = Loader()
        self.doom_dir = os.path.dirname(os.path.abspath(__file__))
        self._mode = 'algo'                         # 'algo' or 'human'
        self.no_render = False                      # To disable double rendering in human mode
        self.viewer = None
        self.is_initialized = False                 # Indicates that reset() has been called
        self.curr_seed = 0
        self.lock = (DoomLock()).get_lock()
        self.action_space = spaces.MultiDiscrete([[0, 1]] * 38 + [[-10, 10]] * 2 + [[-100, 100]] * 3)
        self.allowed_actions = list(range(NUM_ACTIONS))
        self.screen_height = 480
        self.screen_width = 640
        self.screen_resolution = ScreenResolution.RES_640X480
        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
        self._seed()
        self._configure()

    def _configure(self, lock=None, **kwargs):
        if 'screen_resolution' in kwargs:
            logger.warn('Deprecated - Screen resolution must now be set using a wrapper. See documentation for details.')
        # Multiprocessing lock
        if lock is not None:
            self.lock = lock

    def _load_level(self):
        # Closing if is_initialized
        if self.is_initialized:
            self.is_initialized = False
            self.game.close()
            self.game = DoomGame()

        # Customizing level
        if getattr(self, '_customize_game', None) is not None and callable(self._customize_game):
            self.level = -1
            self._customize_game()

        else:
            # Loading Paths
            if not self.is_initialized:
                self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
                self.game.set_doom_game_path(self.loader.get_freedoom_path())

            # Common settings
            self.game.load_config(os.path.join(self.doom_dir, 'assets/%s' % DOOM_SETTINGS[self.level][CONFIG]))
            self.game.set_doom_scenario_path(self.loader.get_scenario_path(DOOM_SETTINGS[self.level][SCENARIO]))
            if DOOM_SETTINGS[self.level][MAP] != '':
                self.game.set_doom_map(DOOM_SETTINGS[self.level][MAP])
            self.game.set_doom_skill(DOOM_SETTINGS[self.level][DIFFICULTY])
            self.allowed_actions = DOOM_SETTINGS[self.level][ACTIONS]
            self.game.set_screen_resolution(self.screen_resolution)

        self.previous_level = self.level
        self._closed = False

        # Algo mode
        if 'human' != self._mode:
            self.game.set_window_visible(False)
            self.game.set_mode(Mode.PLAYER)
            self.no_render = False
            try:
                with self.lock:
                    self.game.init()
            except (ViZDoomUnexpectedExitException, ViZDoomErrorException):
                raise error.Error(
                    'VizDoom exited unexpectedly. This is likely caused by a missing multiprocessing lock. ' +
                    'To run VizDoom across multiple processes, you need to pass a lock when you configure the env ' +
                    '[e.g. env.configure(lock=my_multiprocessing_lock)], or create and close an env ' +
                    'before starting your processes [e.g. env = gym.make("DoomBasic-v0"); env.close()] to cache a ' +
                    'singleton lock in memory.')
            self._start_episode()
            self.is_initialized = True
            return self.game.get_state().image_buffer.copy()

        # Human mode
        else:
            self.game.add_game_args('+freelook 1')
            self.game.set_window_visible(True)
            self.game.set_mode(Mode.SPECTATOR)
            self.no_render = True
            with self.lock:
                self.game.init()
            self._start_episode()
            self.is_initialized = True
            self._play_human_mode()
            return np.zeros(shape=self.observation_space.shape, dtype=np.uint8)

    def _start_episode(self):
        if self.curr_seed > 0:
            self.game.set_seed(self.curr_seed)
            self.curr_seed = 0
        self.game.new_episode()
        return

#.........这里部分代码省略.........
开发者ID:shanlior,项目名称:gym-doom,代码行数:101,代码来源:doom_env.py

示例15: DoomCorridorEnv

class DoomCorridorEnv(doom_env.DoomEnv):
    """
    ------------ Training Mission 2 - Corridor ------------
    This map is designed to improve your navigation. There is a vest
    at the end of the corridor, with 6 enemies (3 groups of 2). Your goal
    is to get to the vest as soon as possible, without being killed.

    Allowed actions:
        [0]  - ATTACK                           - Shoot weapon - Values 0 or 1
        [9]  - MOVE_RIGHT                       - Move to the right - Values 0 or 1
        [10] - MOVE_LEFT                        - Move to the left - Values 0 or 1
        [12] - MOVE_FORWARD                     - Move forward - Values 0 or 1
        [13] - TURN_RIGHT                       - Turn right - Values 0 or 1
        [14] - TURN_LEFT                        - Turn left - Values 0 or 1
    Note: see controls.md for details

    Rewards:
        + dX    - For getting closer to the vest
        - dX    - For getting further from the vest
        -100    - Penalty for being killed

    Goal: 1,270 points
     Reach the vest (try also killing guards, rather than just running)

    Ends when:
        - Player touches vest
        - Player is dead
        - Timeout (1 minutes - 2,100 frames)
    -----------------------------------------------------
    """
    def __init__(self):
        super(DoomCorridorEnv, self).__init__()
        package_directory = os.path.dirname(os.path.abspath(__file__))
        self.loader = Loader()
        self.game = DoomGame()
        self.game.load_config(os.path.join(package_directory, 'assets/deadly_corridor.cfg'))
        self.game.set_vizdoom_path(self.loader.get_vizdoom_path())
        self.game.set_doom_game_path(self.loader.get_freedoom_path())
        self.game.set_doom_scenario_path(self.loader.get_scenario_path('deadly_corridor.wad'))
        self.screen_height = 480                    # Must match .cfg file
        self.screen_width = 640                     # Must match .cfg file
        # action indexes are [0, 9, 10, 12, 13, 14]
        self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 6))
        self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
        self.game.set_window_visible(False)
        self.viewer = None
        self.game.init()
        self.game.new_episode()
开发者ID:Eulerianial,项目名称:gym,代码行数:48,代码来源:doom_corridor.py


注:本文中的doom_py.DoomGame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。