Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
game = vzd.DoomGame()
# Use other config file if you wish.
game.load_config(args.config)
game.set_render_hud(False)
game.set_screen_resolution(vzd.ScreenResolution.RES_640X480)
# Enables information about all objects present in the current episode/level.
game.set_objects_info_enabled(True)
# Enables information about all sectors (map layout).
game.set_sectors_info_enabled(True)
game.clear_available_game_variables()
game.add_available_game_variable(vzd.GameVariable.POSITION_X)
game.add_available_game_variable(vzd.GameVariable.POSITION_Y)
game.add_available_game_variable(vzd.GameVariable.POSITION_Z)
game.init()
actions = [[True, False, False], [False, True, False], [False, False, True]]
episodes = 10
sleep_time = 1.0 / vzd.DEFAULT_TICRATE # = 0.028
for i in range(episodes):
print("Episode #" + str(i + 1))
# Not needed for the first episode but the loop is nicer.
game.new_episode()
while not game.is_episode_finished():
game = vzd.DoomGame()
# Use other config file if you wish.
game.load_config(args.config)
game.set_render_hud(False)
game.set_screen_resolution(vzd.ScreenResolution.RES_640X480)
# Set cv2 friendly format.
game.set_screen_format(vzd.ScreenFormat.BGR24)
# Enables labeling of the in game objects.
game.set_labels_buffer_enabled(True)
game.clear_available_game_variables()
game.add_available_game_variable(vzd.GameVariable.POSITION_X)
game.add_available_game_variable(vzd.GameVariable.POSITION_Y)
game.add_available_game_variable(vzd.GameVariable.POSITION_Z)
game.init()
actions = [[True, False, False], [False, True, False], [False, False, True]]
episodes = 10
# Sleep time between actions in ms
sleep_time = 28
# Prepare some colors and drawing function
# Colors in in BGR order
doom_red_color = [0, 0, 203]
game.load_config(args.config)
game.set_render_hud(False)
game.set_screen_resolution(vzd.ScreenResolution.RES_640X480)
# Set cv2 friendly format.
game.set_screen_format(vzd.ScreenFormat.BGR24)
# Enables rendering of automap.
game.set_automap_buffer_enabled(True)
# All map's geometry and objects will be displayed.
game.set_automap_mode(vzd.AutomapMode.OBJECTS_WITH_SIZE)
game.add_available_game_variable(vzd.GameVariable.POSITION_X)
game.add_available_game_variable(vzd.GameVariable.POSITION_Y)
game.add_available_game_variable(vzd.GameVariable.POSITION_Z)
# Disables game window (FPP view), we just want to see the automap.
game.set_window_visible(False)
# This CVAR can be used to make a map follow a player.
game.add_game_args("+am_followplayer 1")
# This CVAR controls scale of rendered map (higher valuer means bigger zoom).
game.add_game_args("+viz_am_scale 10")
# This CVAR shows the whole map centered (overrides am_followplayer and viz_am_scale).
game.add_game_args("+viz_am_center 1")
# Map's colors can be changed using CVARs, full list is available here: https://zdoom.org/wiki/CVARs:Automap#am_backcolor