How to use the vizdoom.ScreenFormat.GRAY8 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 mihahauke / deep_rl_vizdoom / test_wrapper_performance.py View on Github external
if doom_wrapper.is_terminal():
            doom_wrapper.reset()
    end = time()
    wrapper_t = (end - start)

    # Vanilla vizdoom:
    doom = vzd.DoomGame()
    if "scenarios_path" not in settings:
        scenarios_path = vzd.__path__[0] + "/scenarios"
    else:
        scenarios_path = settings["scenarios_path"]
    config_file = scenarios_path + "/" + settings["config_file"]
    doom.load_config(config_file)
    doom.set_window_visible(False)
    doom.set_screen_format(vzd.ScreenFormat.GRAY8)
    doom.set_screen_resolution(vzd.ScreenResolution.RES_160X120)
    doom.init()
    actions = [list(a) for a in it.product([0, 1], repeat=len(doom.get_available_game_variables()))]
    start = time()
    frame_skip = settings["frame_skip"]
    for _ in trange(iters, leave=False):
        if doom.is_episode_finished():
            doom.new_episode()
        doom.make_action(choice(actions), frame_skip)

    end = time()
    vanilla_t = end - start
    print(green("\twrapper: {:0.2f} steps/s".format(iters / wrapper_t)))
    print(green("\twrapper: {:0.2f} s/1000 steps".format(wrapper_t / iters * 1000)))
    print(blue("\tvanilla: {:0.2f} steps/s".format(iters / vanilla_t)))
    print(blue("\tvanilla: {:0.2f} s/1000 steps\n".format(vanilla_t / iters * 1000)))
github mihahauke / deep_rl_vizdoom / vizdoom_wrapper.py View on Github external
**kwargs):
        doom = vzd.DoomGame()
        if sound:
            doom.set_sound_enabled(True)
        if force_freedoom:
            doom.set_doom_game_path(vzd.__path__[0] + "/freedoom2.wad")

        doom.load_config(os.path.join(scenarios_path, str(config_file)))
        if hide_hood:
            doom.set_render_hud(not hide_hood)

        doom.set_window_visible(display)
        if display and smooth_display:
            doom.add_game_args("+viz_render_all 1")
        # TODO support for colors
        doom.set_screen_format(vzd.ScreenFormat.GRAY8)
        if vizdoom_async_mode:
            doom.set_mode(vzd.Mode.ASYNC_PLAYER)
            doom.set_ticrate(int(fps))
        else:
            doom.set_mode(vzd.Mode.PLAYER)

        if seed is not None:
            doom.set_seed(seed)

        # TODO if eval fails, show some warning
        doom.set_screen_resolution(eval("vzd.ScreenResolution." + vizdoom_resolution))
        if not noinit:
            doom.init()
        self.doom = doom

        self._stack_n_frames = stack_n_frames
github rlgraph / rlgraph / rlgraph / environments / vizdoom.py View on Github external
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 mwydmuch / ViZDoom / examples / python / learning_tensorflow.py View on Github external
def initialize_vizdoom(config_file_path):
    print("Initializing doom...")
    game = vzd.DoomGame()
    game.load_config(config_file_path)
    game.set_window_visible(False)
    game.set_mode(vzd.Mode.PLAYER)
    game.set_screen_format(vzd.ScreenFormat.GRAY8)
    game.set_screen_resolution(vzd.ScreenResolution.RES_640X480)
    game.init()
    print("Doom initialized.")
    return game
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)
github mihahauke / VDAIC2017 / intelact / IntelAct_track2 / agent / doom_simulator.py View on Github external
if 'ticrate' in args:
            self._game.set_ticrate(args['ticrate'])

        # set resolution
        try:
            self._game.set_screen_resolution(getattr(vizdoom.ScreenResolution, 'RES_%dX%d' % self.resolution))
        except:
            print("Requested resolution not supported:", sys.exc_info()[0])
            raise

        # set color mode
        if self.color_mode == 'RGB':
            self._game.set_screen_format(vizdoom.ScreenFormat.CRCGCB)
            self.num_channels = 3
        elif self.color_mode == 'GRAY':
            self._game.set_screen_format(vizdoom.ScreenFormat.GRAY8)
            self.num_channels = 1
        else:
            print("Unknown color mode")
            raise

        self.available_controls, self.continuous_controls, self.discrete_controls = self.analyze_controls(self.config)
        self.num_buttons = self._game.get_available_buttons_size()
        assert (self.num_buttons == len(self.discrete_controls) + len(self.continuous_controls))
        assert (len(self.continuous_controls) == 0)  # only discrete for now
        self.num_meas = self._game.get_available_game_variables_size()

        self.game_initialized = False
github intel-isl / DirectFuturePrediction / DFP / doom_simulator.py View on Github external
# set resolution
        try:
            self._game.set_screen_resolution(getattr(vizdoom.ScreenResolution, 'RES_%dX%d' % self.resolution))
            self.resize = False
        except:
            print("Requested resolution not supported:", sys.exc_info()[0], ". Setting to 160x120 and resizing")
            self._game.set_screen_resolution(getattr(vizdoom.ScreenResolution, 'RES_160X120'))
            self.resize = True

        # set color mode
        if self.color_mode == 'RGB':
            self._game.set_screen_format(vizdoom.ScreenFormat.CRCGCB)
            self.num_channels = 3
        elif self.color_mode == 'GRAY':
            self._game.set_screen_format(vizdoom.ScreenFormat.GRAY8)
            self.num_channels = 1
        else:
            print("Unknown color mode")
            raise

        self.available_controls, self.continuous_controls, self.discrete_controls = self.analyze_controls(self.config)
        self.num_buttons = self._game.get_available_buttons_size()
        assert(self.num_buttons == len(self.discrete_controls) + len(self.continuous_controls))
        assert(len(self.continuous_controls) == 0) # only discrete for now
        self.num_meas = self._game.get_available_game_variables_size()
            
        self.meas_tags = []
        for nm in range(self.num_meas):
            self.meas_tags.append('meas' + str(nm))
            
        self.episode_count = 0