-
Notifications
You must be signed in to change notification settings - Fork 28
Java Framework (How to Run)
Class Test.java
contains functionality for running the framework. It follows several steps, as follows:
Game game = new Game(seed, boardSize, gameMode, gameIDstr);
-
seed
= random seed used for board generation. The game is otherwise deterministic. -
boardSize
= size of the board for this game. -
gameMode
= mode of game, fromutils.Types.GAME_MODE
enum. -
gameIDstr
= string by which this game should be identified for replay purposes, can be left empty ("").
KeyController ki1 = new KeyController(true); // Primary keys: arrows + space bar)
KeyController ki2 = new KeyController(false); // Secondary keys: WASD + right shift
All players will be added into an ArrayList: ArrayList<Player> players = new ArrayList<>();
The order in which they are added into the list defines the player order (i.e. first player in the list will be player 0). This list MUST contain 4 players.
The general constructor followed by all players receives a random seed
and a playerID
. The player ID is an integer in [10, 13]. All player IDs are defined as types in utils.Types.TILETYPE
, with the first player being utils.Types.TILETYPE.AGENT0
.
See AI Players page for all AI player options.
After 4 players are added into the list, the game can be informed of the players: game.setPlayers(players);
Run.runGame(game, ki1, ki2, useSeparateThreads);
This method runs the given game one time. The useSeparateThreads
flag may be set to true if the agents should run in parallel at every game tick when making decisions about their next actions (useful in speeding up execution with agents which take longer to make decisions, such as MCTS and RHEA).
game.setLogGame(true);
may be used before running a game to log the given run.
Game.getLastReplayGame();
would then retrieve the last game for which actions were logged. This game instance can then be used to run the replay as with a normal game:
Game replay = Game.getLastReplayGame();
Run.runGame(replay, ki1, ki2, useSeparateThreads);
The GameLog.JSON_GAMELOGS_PATH
and GameLog.GAMELOGS_PATH
static variables define where the logged games will be stored, depending on whether Game.LOG_JSON
is set to true (so the game will be logged in JSON format) or false (the game log will be serialized), respectively.
Run.runGames(game, new long[]{seed}, N, useSeparateThreads);
This method runs the given game N
times, possibly in separate threads, using the random seeds supplied in an array. If N
random seeds are given, then each instance of the game will use a new board generated with the corresponding random seed.
- Home
- Pommerman Game Rules
- Py-Pommerman
- Java-Pommerman
- Docker
- Python-Java Connection