-
Notifications
You must be signed in to change notification settings - Fork 5
/
spectator.py
40 lines (31 loc) · 1.01 KB
/
spectator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
from __future__ import print_function
import argparse
from time import sleep
from vizdoom import *
parser = argparse.ArgumentParser()
parser.add_argument('wad')
flags = parser.parse_args()
if __name__ == '__main__':
game = DoomGame()
game.load_config("./content/default.cfg")
game.set_doom_scenario_path(flags.wad)
game.add_game_args("+freelook 1")
game.set_screen_resolution(ScreenResolution.RES_640X480)
game.set_window_visible(True)
game.set_mode(Mode.SPECTATOR)
game.init()
episodes = 10
for i in range(episodes):
print("Episode #" + str(i + 1))
game.new_episode()
while not game.is_episode_finished():
state = game.get_state()
game.advance_action()
last_action = game.get_last_action()
reward = game.get_last_reward()
print("Episode finished!")
print("Total reward:", game.get_total_reward())
print("************************")
sleep(2.0)
game.close()