Skip to content

Running the Framework

Raluca D. Gaina edited this page Jun 9, 2020 · 4 revisions

Running a game

The main method in the core.Game.java class allows for running any game registered in the framework (i.e. those available in the games.GameType.java enum).

1. Choose on/off visuals

Set the ActionController ac variable to null if running without visuals, or leave as-is to enable visuals (if the game chosen has a GUI implemented).

2. Setting the random seed for the game

Set the seed variable to the specific seed you wish to run the game with (or leave to System.currentTimeMillis() for a new random value): long seed = System.currentTimeMillis();

3. Choose players for the game

Add to the players array instances of the agents you wish to run the game with. HumanConsolePlayer can be used to play as a human interacting with the game via the console. HumanGUIPlayer can be used to play as a human interacting with the game via the GUI (if implemented).

        ArrayList<AbstractPlayer> players = new ArrayList<>();
        players.add(new RandomPlayer(new Random()));
        players.add(new RandomPlayer(new Random()));
        players.add(new RandomPlayer(new Random()));
        players.add(new OSLA());

4. Run!

Choose final parameters for the method call:

private static Game runOne(GameType gameToPlay, List<AbstractPlayer> players, long seed, ActionController ac,
                               boolean randomizeParameters);
  • gameToPlay: the type of the game to play
  • players: previously defined players array
  • seed: previously defined seed variable
  • ac: previously defined ac variable
  • randomizeParameters: true if game parameters should be randomized (if implemented for the game), false otherwise.

Adjust settings for the following variables in class core.CoreConstants.java if needed:

    public final static boolean VERBOSE = true;
    public final static boolean PARTIAL_OBSERVABLE = false;
    public final static boolean DISQUALIFY_PLAYER_ON_ILLEGAL_ACTION_PLAYED = false;

Finally, run the Game.java class.

Running multiple games

To run multiple games, choose one of the following methods, depending on whether you wish to run with a fixed random seed for all games (1, passing desired seed to the method), with a new random seed for each run (1, passing null to the seed parameter in the method) or with fixed random seed for each repetition of each game (2):

  1. private static void runMany(List<GameType> gamesToPlay, List<AbstractPlayer> players, Long seed, int nRepetitions, ActionController ac, boolean randomizeParameters)
  2. private static void runMany(List<GameType> gamesToPlay, List<AbstractPlayer> players, int nRepetitions, long[] seeds, ActionController ac, boolean randomizeParameters)

Use the chosen function and parameters in the core.Game.main function as before, and run the Game class.

Notes:

  • Games within a specific category can be obtained by using the GameType.Category.getAllGames() method, e.g. GameType.Category.Strategy.getAllGames() would return a list of all games in the "Strategy" category.
  • Games using a specific mechanic can be obtained by using the GameType.Mechanic.getAllGames() method, e.g. GameType.Mechanic.Cooperative.getAllGames() would return a list of all cooperative games.

Running tournaments

To do, use any classes available in the evaluation package.

Clone this wiki locally