Skip to content
Lord of Galaxy edited this page Aug 12, 2022 · 5 revisions

Pioneering Pandora Dev-Kit

This is the dev-kit for Pioneering Pandora. Please file bug reports either by using the contact form, or by submitting an issue. Consider reading the basic tutorial after you have gone through this document.

Downloading and Installing

Download pandora-dev-kit.zip from the latest release and extract.

The dev-kit has currently been tested on Python 3.10 only, but is expected to work with Python 3.7+. It is recommended you create a separate venv for testing your bots by using python -m venv venv (refer to the official documentation for more information on venv). Activate the venv (venv\Scripts\activate on Windows) and install all prerequisites by running pip install -r requirements.txt.

Using the Dev-Kit

The dev-kit comes with a few sample games (in game_logs). To view these, and any games you run, first run the command python server.py and then open localhost:8000 to see a list of all available games. To run your own games, run python main.py. You can then view the game (assuming it has been logged) by following the previous instructions.

Advanced Usage

To make full use of the dev-kit, it is necessary to understand main.py. We shall focus on the lines that matter the most:

p1t = Player
p2t = Player
params = GameParams()
g = Game(4, p1t, p2t, game_params=params, seed=100)
g.play(log=True, log_p=False)

The first two lines define the types (classes) for the first and second player respectively. They may or may not be the same. For example, to test your agent against an agent that does nothing, import NullPlayer from agent.py, and use p2t = NullPlayer.

The next line defines the (constant) parameters used for the game. You may modify these to test different scenarios. For instance, to make MINERs cheaper, you could use params.miners.ore_cost = 5. Keep in mind that these parameters may change during the course of the event, so you should not rely upon the defaults supplied to you. Refer to params.py for information about all the different parameters.

Next, we initialize a Game object, which is the main class that encapsulates a single game. The constructor has three necessary parameters (in order): the game ID, and the types for the first and second player respectively. Additionally, it has three keyword-only arguments. These are:

  • seed - the seed for the random number generator, used for consistency between runs
  • game_params - the parameters used for the game, as described above
  • time_limits - time controls for the game, which are not used in the dev-kit, but will be enforced during the event

Finally, the Game.play method is used to actually run the game. It accepts two boolean parameters, log and log_p (in that order). If log is set (i.e. True), the game will produce a log file in the game_logs folder with the name game_<game ID>.plog, so that you may view the game. If log_p is set, the game map is printed to the terminal after every move, so that you can track your agent as the game is running. If it is not set, the player scores are printed every 50 moves instead.

Please refer to the basic tutorial for more information.

Clone this wiki locally