StephenGss / PAL

Polycraft World AI Lab
3 stars 6 forks source link

Release 2.0

The latest release of the Polycraft Tournament Manager includes major updates to our POGO and HUGA task design. The example tournament in pogo_100_PN has also been updated to the new POGO version. We've also added an example tournament for the HUGA task in huga_100_PN.

Key Updates

Release 1.3

Installation:

1. Ubuntu

  1. If you haven't already, pull this branch of the repository to your work directory: git clone -b release_2.0 --single-branch https://github.com/StephenGss/pal.git
  2. For a fresh install:
    • navigate to polycraft/pal/setup/ and execute ./setup_linux_headless.sh (may need sudo permissions).
    • We have also provided our current setup scripts in that folder (they include a few additional packages enabling us to upload tournament results to SQL) for your reference.
  3. For a pre-existing environment, review the apt-get commands in _setup_linuxshortened.sh and execute as-needed.
  4. pip install all requirements. We recommend using a package manager like conda
    • conda create --name pal_manager python=3.8 # or use your favorite venv
    • cd polycraft/pal/ && python -m pip install -r requirements.txt
  5. unzip and move to a known location the zipped tournament JSONs. We recommend testing the setup with a VIRGIN No Novelty variant
Possible issues

2. Windows

Launching & Running:

The main program is found in the PolycraftAIGym folder, called LaunchTournament.py

A key release update has created a new file, config.py containing all config variables necessary for program execution (previously, these were variables simply declared in this file)

These variables can be edited directly in that file. However, LaunchTournament.py can also take in command line arguments to adjust the defaults.

These parameters must be adjusted for each user's system to enable the Tournament Manager to run. Please read carefully the sections below on parameter details and adjust to match your folder structure.

After setting configs, please adjust runtime settings by:

  1. Changing to PolycraftAIGym as the work directory:
    cd /path/to/polycraft/pal/PolycraftAIGym
  2. If your Operating System is Windows, Modify PAL/PolycraftAIGym/LaunchTournament.py's if name == main(): function (found at the very bottom) as follows:
    • pal = LaunchTournament('WIN')
    • passing in "UNIX" (default) will run the _UNIX version of the agent command and PAL command in the CONFIG file as well as tweak the expectations for line endings to not have carriage returns
  3. To execute:
    python LaunchTournament.py {-h, -i, etc} (run the manager, optionally passing in flags listed below)

Setting Config Variables

Below is an exhaustive list of variables defined in config.py and their associated CLI flag to override their values (where applicable).

Critical Parameters requiring edits before runtime are:

Parameter CLI flag Comments
MAX_STEP_COST N/A (see file) Maximum step cost before a game is ended - set to 1,000,000
PAL_COMMAND N/A (see file) Windows command to execute the polycraft client
PAL_COMMAND_UNIX N/A (see file) Linux command to run polycraft.
MAX_TIME -i <time> maximum time in seconds for a given game (default: 300)
TOURNAMENT_ID -t <name> name of the tournament
AGENT_DIRECTORY -d <../agent/> work directory where AGENT_COMMAND_UNIX gets executed
AGENT_COMMAND_UNIX -x <bash cmd> command necessary to launch the Agent AI
AGENT_COMMAND -x <windows cmd> -x modifies both parameters (OS-agnostic)
AGENT_ID -a <agent_name> name of agent
GAME_COUNT -c <count> number of games to be played. If count > number of games available in the games folder, all games are played.
GAMES_FOLDER -g <games/> location of folder containing tournament JSONs.

NOTE: the PAL_COMMAND_UNIX must be adjusted away from default to run on a computer with a graphics card & display attached. Please see the related comment in the config.py file, as the appropriate UNIX command (./gradlew runclient).

Running with CLI Commands

Here is an example of running the manager with flags passed:

>> cd /path/to/polycraft/pal/PolycraftAIGym
>> python LaunchTournament.py -t "Tournament1" -a "My_Agent" -d "../agents/my_agent_folder/"
... -x "./launch_my_agent.sh" -g "../path/to/tournament/jsons/" -c 10 -i 600

Will launch a tournament named "Tournament1" using _"MyAgent" found in _"../agents/my_agentfolder/" executed with _"launch_myagent.sh" playing the first 10 games (sorted by the name of the JSON - see below) found in folder "../path/to/tournament/jsons/" with 600 seconds of time per game.

Interacting with Polycraft AI Lab, platform independent

Polycraft Bot API

The Polycraft World AI API consists of 28 total different API commands at Release 1.5.0 on 5.4.2020. These commands are broken down into SYSTEM commands, DEV commands, and GAME commands. The GAME commands are further divided into MOVE commands, SENSE commands, INTERACT commands.

SYSTEM commands: (2 total)

DEV commands: (4 total)

GAME commands - MOVE commands: (7 total)

GAME commands - SENSE commands: (8 total)

GAME commands - INTERACT/ACTION commands: (9 total)