3
3
from __future__ import print_function
4
4
from vizdoom import *
5
5
from random import choice
6
+
7
+ # For multiplayer game use process (ZDoom's multiplayer sync mechanism prevents threads to work as expected).
6
8
from multiprocessing import Process
7
9
10
+ # For singleplayer games threads can also be used.
11
+ #from threading import Thread
12
+
8
13
def player1 ():
9
14
game = DoomGame ()
15
+
16
+ #game.load_config('../config/basic.cfg')
17
+ # or
10
18
game .load_config ('../config/multi_duel.cfg' )
11
- game .add_game_args ("-host 2 -deathmatch +timelimit 1.0 +sv_forcerespawn 1 +sv_respawnprotect 1 +sv_spawnfarthest 1" )
12
- game .add_game_args ("+name PLAYER1" )
19
+ game .add_game_args ("-host 2 -deathmatch +timelimit 1.0 +sv_spawnfarthest 1" )
20
+ game .add_game_args ("+name Player1" )
21
+
13
22
game .init ()
14
23
15
24
actions = [[True ,False ,False ],[False ,True ,False ],[False ,False ,True ]]
@@ -25,9 +34,13 @@ def player1():
25
34
26
35
def player2 ():
27
36
game = DoomGame ()
37
+
38
+ #game.load_config('../config/basic.cfg')
39
+ # or
28
40
game .load_config ('../config/multi_duel.cfg' )
29
41
game .add_game_args ("-join 127.0.0.1" )
30
- game .add_game_args ("+name PLAYER2" )
42
+ game .add_game_args ("+name Player2" )
43
+
31
44
game .init ()
32
45
33
46
actions = [[True ,False ,False ],[False ,True ,False ],[False ,False ,True ]]
@@ -41,8 +54,10 @@ def player2():
41
54
42
55
game .close ()
43
56
57
+ #p1 = Thread(target = player1)
58
+ #p1.start()
44
59
45
- p1 = Process (target = player1 )
60
+ p1 = Process (target = player1 )
46
61
p1 .start ()
47
62
48
63
player2 ()
0 commit comments