Skip to content

Commit a93c096

Browse files
committed
Imprved multiple_instances example
Former-commit-id: 99f34e3
1 parent b3ddab8 commit a93c096

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

examples/python/mutliple_instances.py renamed to examples/python/multiple_instances.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
from __future__ import print_function
44
from vizdoom import *
55
from random import choice
6+
7+
# For multiplayer game use process (ZDoom's multiplayer sync mechanism prevents threads to work as expected).
68
from multiprocessing import Process
79

10+
# For singleplayer games threads can also be used.
11+
#from threading import Thread
12+
813
def player1():
914
game = DoomGame()
15+
16+
#game.load_config('../config/basic.cfg')
17+
# or
1018
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+
1322
game.init()
1423

1524
actions = [[True,False,False],[False,True,False],[False,False,True]]
@@ -25,9 +34,13 @@ def player1():
2534

2635
def player2():
2736
game = DoomGame()
37+
38+
#game.load_config('../config/basic.cfg')
39+
# or
2840
game.load_config('../config/multi_duel.cfg')
2941
game.add_game_args("-join 127.0.0.1")
30-
game.add_game_args("+name PLAYER2")
42+
game.add_game_args("+name Player2")
43+
3144
game.init()
3245

3346
actions = [[True,False,False],[False,True,False],[False,False,True]]
@@ -41,8 +54,10 @@ def player2():
4154

4255
game.close()
4356

57+
#p1 = Thread(target = player1)
58+
#p1.start()
4459

45-
p1 = Process(target=player1)
60+
p1 = Process(target = player1)
4661
p1.start()
4762

4863
player2()

scenarios/multi_duel.wad

-3.87 KB
Binary file not shown.

0 commit comments

Comments
 (0)