forked from Farama-Foundation/ViZDoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticrate.py
executable file
·52 lines (32 loc) · 996 Bytes
/
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
#!/usr/bin/env python
from __future__ import print_function
from multiprocessing import Process
from random import choice
from vizdoom import *
def play(game):
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()
def player1():
game = DoomGame()
game.load_config('../config/basic.cfg')
game.set_mode(Mode.ASYNC_PLAYER)
# Default Doom's ticrate is 35 per second, so this one will work 2 times faster.
game.set_ticrate(70)
play(game)
def player2():
game = DoomGame()
game.load_config('../config/basic.cfg')
game.set_mode(Mode.ASYNC_PLAYER)
# And this one will work 2 times slower.
game.set_ticrate(17)
play(game)
if __name__ == '__main__':
p1 = Process(target=player1)
p1.start()
player2()