#!/usr/bin/env python3 ##################################################################### # This script presents how to use Doom's native demo mechanism to # replay episodes with perfect accuracy. ##################################################################### from __future__ import print_function from vizdoom import * game = DoomGame() # Use other config file if you wish. game.load_config("../../scenarios/comes-w-vizdoom/basic.cfg") game.set_episode_timeout(300) # Record episodes while playing in 320x240 resolution without HUD game.set_screen_resolution(ScreenResolution.RES_320X240) game.set_render_hud(False) # Episodes can be recorder in any available mode (PLAYER, ASYNC_PLAYER, SPECTATOR, ASYNC_SPECTATOR) episodes = 1 # New render settings for replay game.set_screen_resolution(ScreenResolution.RES_800X600) game.set_render_hud(True) # Replay can be played in any mode. # BUG: Result is incorrect when using Mode.PLAYER. game.set_mode(Mode.PLAYER) #game.set_mode(Mode.SPECTATOR) game.set_window_visible(False) game.init() print("\nREPLAY OF EPISODE") print("************************\n") for i in range(episodes): # Replays episodes stored in given file. Sending game command will interrupt playback. game.replay_episode("../../test/doom_recordings/basic/basic-stand-there-do-nothing-300-timeout.lmp") while not game.is_episode_finished(): s = game.get_state() # Use advance_action instead of make_action. game.advance_action() r = game.get_last_reward() # game.get_last_action is not supported and don't work for replay at the moment. print("State #" + str(s.number)) print("Game variables:", s.game_variables[0]) print("Reward:", r) print("=====================") print("Episode finished.") print("total reward:", game.get_total_reward()) print("************************") game.close()