forked from Farama-Foundation/ViZDoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMultiplayerHost.java
41 lines (27 loc) · 1.24 KB
/
MultiplayerHost.java
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
import vizdoom.*;
import java.util.*;
import java.lang.*;
public class MultiplayerHost {
public static void main (String[] args) {
DoomGame game = new DoomGame();
System.out.println("\n\nnMULTIPLAYER HOST EXAMPLE\n");
game.loadConfig("../../examples/config/multi.cfg");
// Select game and map You want to use.
game.setDoomGamePath("../../scenarios/freedoom2.wad");
//game.setDoomGamePath("../../scenarios/doom2.wad"); // Not provided with environment due to licences.
// Host game.
game.addGameArgs("-host 2 -deathmatch +map map01");
game.setMode(Mode.ASYNC_SPECTATOR); // Multiplayer requires the use of asynchronous modes.
game.init();
while(!game.isEpisodeFinished()){ // Play until the game (episode) is over.
if(game.isPlayerDead()){ // Check if player is dead
game.respawnPlayer(); // Use this to respawn immediately after death, new state will be available.
// Or observe the game until automatic respawn.
// game.advanceAction();
// continue;
}
game.advanceAction();
}
game.close();
}
}