-
-
Notifications
You must be signed in to change notification settings - Fork 404
/
ticrate.py
executable file
·65 lines (48 loc) · 1.56 KB
/
ticrate.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
import os
from argparse import ArgumentParser
from multiprocessing import Process
from random import choice
import vizdoom as vzd
DEFAULT_CONFIG = os.path.join(vzd.scenarios_path, "basic.cfg")
def play(config_file, ticrate=35):
game = vzd.DoomGame()
game.load_config(config_file)
game.set_mode(vzd.Mode.ASYNC_PLAYER)
game.set_ticrate(ticrate)
game.init()
actions = [[True, False, False], [False, True, False], [False, False, True]]
episodes = 10
for i in range(episodes):
game.new_episode()
while not game.is_episode_finished():
game.make_action(choice(actions))
game.close()
if __name__ == "__main__":
if __name__ == "__main__":
parser = ArgumentParser(
"ViZDoom example showing how to change the ticrate for asynchronous mode."
)
parser.add_argument(
dest="config",
default=DEFAULT_CONFIG,
nargs="?",
help="Path to the configuration file of the scenario."
" Please see "
"../../scenarios/*cfg for more scenarios.",
)
parser.add_argument(
"-t",
"--ticrates",
default=[17, 35, 70],
nargs="+",
help="List of ticrates to show.",
)
args = parser.parse_args()
processes = []
for ticrate in args.ticrates:
p = Process(target=play, args=[args.config, ticrate])
p.start()
processes.append(p)
for p in processes:
p.join()