How to use the vizdoom.ScreenResolution function in vizdoom

To help you get started, we’ve selected a few vizdoom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chainer / chainerrl / chainerrl / envs / doom_env.py View on Github external
seed = np.random.randint(0, 2 ** 16)
        game.set_seed(seed)

        # Load a config file
        game.load_config(os.path.join(
            vizdoom_dir, "examples", 'config', scenario + '.cfg'))

        # Replace default relative paths with actual paths
        game.set_vizdoom_path(os.path.join(vizdoom_dir, "bin/vizdoom"))
        game.set_doom_game_path(
            os.path.join(vizdoom_dir, 'scenarios/freedoom2.wad'))
        game.set_doom_scenario_path(
            os.path.join(vizdoom_dir, 'scenarios', scenario + '.wad'))

        # Set screen settings
        resolutions = {640: ScreenResolution.RES_640X480,
                       320: ScreenResolution.RES_320X240,
                       160: ScreenResolution.RES_160X120}
        game.set_screen_resolution(resolutions[resolution_width])
        game.set_screen_format(ScreenFormat.RGB24)
        game.set_window_visible(window_visible)
        game.set_sound_enabled(window_visible)

        game.init()
        self.game = game

        # Use one-hot actions
        self.n_actions = game.get_available_buttons_size()
        self.actions = []
        for i in range(self.n_actions):
            self.actions.append([i == j for j in range(self.n_actions)])
github flyyufelix / C51-DDQN-Keras / c51_ddqn.py View on Github external
# save the model which is under training
    def save_model(self, name):
        self.model.save_weights(name)

if __name__ == "__main__":

    # Avoid Tensorflow eats up GPU memory
    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    sess = tf.Session(config=config)
    K.set_session(sess)

    game = DoomGame()
    game.load_config("../../scenarios/defend_the_center.cfg")
    game.set_sound_enabled(True)
    game.set_screen_resolution(ScreenResolution.RES_640X480)
    game.set_window_visible(False)
    game.init()

    game.new_episode()
    game_state = game.get_state()
    misc = game_state.game_variables  # [KILLCOUNT, AMMO, HEALTH]
    prev_misc = misc

    action_size = game.get_available_buttons_size()

    img_rows , img_cols = 64, 64
    # Convert image into Black and white
    img_channels = 4 # We stack 4 frames

    # C51
    num_atoms = 51
github rlgraph / rlgraph / rlgraph / environments / vizdoom.py View on Github external
def __init__(self, config_file, visible=False, mode=vizdoom.Mode.PLAYER, screen_format=vizdoom.ScreenFormat.GRAY8, screen_resolution=vizdoom.ScreenResolution.RES_640X480):
        """
        Args:
            config_file (str): The config file to configure the DoomGame object.
            visible (bool): 
            mode (vizdoom.Mode): The playing mode of the game.
            screen_format (vizdoom.ScreenFormat): The screen (pixel) format of the game.
            screen_resolution (vizdoom.ScreenResolution): The screen resolution (width x height) of the game.
        """
        # Some restrictions on the settings.
        assert screen_format in [vizdoom.ScreenFormet.RGB24, vizdoom.ScreedFormat.GRAY8], "ERROR: `screen_format` must be either GRAY8 or RGB24!"
        assert screen_resolution in [vizdoom.ScreenResolution.RES_640X480], "ERROR: `screen_resolution` must be 640x480!"

        self.game = vizdoom.DoomGame()
        self.game.load_config(config_file)
        self.game.set_window_visible(False)
        self.game.set_mode(mode)
        self.game.set_screen_format(screen_format)
        self.game.set_screen_resolution(screen_resolution)
        self.game.init()
 
        # Calculate action and state Spaces for Env c'tor.
        state_space = IntBox(255, shape=(480, 480, 1 if screen_format == vizdoom.ScreenFormat.GRAY8 else 3))  # image of size [resolution] with [screen-format] channels
        action_space = IntBox(1, shape=(self.game.get_available_buttons_size(),))

        super(VizDoomEnv, self).__init__(state_space=state_space, action_space=action_space)
github mihahauke / VDAIC2017 / host / host.py View on Github external
game.add_available_button(vzd.Button.MOVE_FORWARD)
    game.add_available_button(vzd.Button.MOVE_BACKWARD)
    game.add_available_button(vzd.Button.TURN_LEFT_RIGHT_DELTA)
    game.add_available_button(vzd.Button.LOOK_UP_DOWN_DELTA)
    game.add_available_button(vzd.Button.SPEED)
    game.add_available_button(vzd.Button.MOVE_UP)
    game.add_available_button(vzd.Button.MOVE_DOWN)

    if watch:
        game.set_mode(vzd.Mode.ASYNC_SPECTATOR)
        game.set_window_visible(True)
    else:
        game.set_mode(vzd.Mode.ASYNC_PLAYER)
        game.set_window_visible(False)

    game.set_screen_resolution(vzd.ScreenResolution.RES_1024X576)

    plural = "s"
    pn = "no"
    if players_num > 1:
        pn = players_num - 1
    if players_num == 2:
        plural = ""

    if record_file is not None and bots_num > 0:
        warn("Recording won't work properly with bots!")

    print("Starting vizdoom CIG 2017 host for {} player{}.".format(pn, plural))
    print("Configuration:")
    print(tabulate([
        ("WAD", WAD_FILE),
        ("TIMELIMIT (min)", timelimit),
github shaohua0116 / demo2program / vizdoom_env / vizdoom_env.py View on Github external
def __init__(self, config='vizdoom_env/asset/default.cfg', verbose=False,
                 perception_type='more_simple'):
        self.verbose = verbose
        self.game = DoomGame()
        self.game.load_config(config)
        if self.verbose:
            self.game.set_window_visible(True)
            self.game.set_screen_resolution(ScreenResolution.RES_1280X960)

        self.game_variables = self.game.get_available_game_variables()
        self.buttons = self.game.get_available_buttons()
        self.action_strings = [b.__str__().replace('Button.', '')
                               for b in self.buttons]
        self.game_variable_strings = [v.__str__().replace('GameVariable.', '')
                                      for v in self.game_variables]
        self.perception_type = perception_type
        if perception_type == 'clear':
            self.distance_dict = CLEAR_DISTANCE_DICT
            self.horizontal_dict = CLEAR_HORIZONTAL_DICT
        elif perception_type == 'simple':
            pass
        elif perception_type == 'more_simple':
            pass
        else: