Skip to content

Automatic Generation of HTN Domains from VGDL Videogame Descriptions

Notifications You must be signed in to change notification settings

IgnacioVellido/VGDL-to-HTN-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VGDL to HTN Parser

VGDL-to-HTN-Parser is a Python parser from VGDL game and level description into HPDL domains and problems.

This research is being developed and partially funded by the Spanish MINECO R&D Project TIN2015-71618-R and RTI2018-098460-B-I00

🔓 Requirements

  • Python3
  • ANTLR 4.7.2 for Python3, see here for more information
  • PyYAML
  • (For replanning only) Java JDK 8 (or superior)

We recommend the use of an anaconda environment to avoid conflicts with other packages.

🔧 Installation

Install ANTLR4 Python3 runtime:

pip install antlr4-python3-runtime==4.7.2

Install PyYAML:

pip install pyyaml

Compile Siadex planner (see the README for requirements):

$ make siadex-planner

💻 Usage

With the exception of the replanning module, all functionally can be called from the makefile.

The available options, with their parameters, are:

- help: Show help

For HPDL:
- hpdl-game: Parse only the VGDL description into a HPDL domain.
    gi: VGDL game description path.

- hpdl-level: Parse the VGDL description and a level
    gi: VGDL game description path.
    li: VGDL level path.


For HPDL execution with SIADEX:
- siadex-compile: Compile Siadex planner

- siadex-run: Call planner
    d: HPDL domain path
    p: HPDL problem path

- siadex-verbose: Call planner in verbose mode
    d: HPDL domain path
    p: HPDL problem path

- siadex-parse-and-run: Parse and call planner
    gi: VGDL game description path
    li: VGDL level path

For PDDL:
- pddl-game: Generate only the PDDL domain
  - gi: VGDL game description path
  - go: Output path

- config: Generate configuration and PDDL domain for a planning-based agent
  - gi: Path to VGDL description file
  - go: Name to be given to the output files

PDDL parser

Note: Generation of PDDL levels is not yet completed, but domains in PPDL1.2 can be produced.

The PDDL parser was made for a planning-based agent (repo can be found here). The subset of the VGDL language accepted is different from the HTN one, but nevertheless bigger, more efficient, and better tested. What's more, as in PDDL the planners handle the plan search, there is no need to define an agent strategy.

Domain and problem generation

For domain and problem generation, you can use the makefile provided or directly the src/main.py script.

usage: main.py [-h] -l {pddl,hpdl} 
                    -gi GAMEINPUT 
                    [-li LEVELINPUT] 
                    [-go GAMEOUTPUT] 
                    [-lo LEVELOUTPUT] 
                    [-vh]

optional arguments:
  -h, --help            Show help message and exit
  -l {pddl,hpdl}, --language {pddl,hpdl}
                        Select output planning language
  -gi GAMEINPUT,    --gameInput GAMEINPUT
                        Input VGDL game file
  -li LEVELINPUT,   --levelInput LEVELINPUT
                        Input VGDL level file
  -go GAMEOUTPUT,   --gameOutput GAMEOUTPUT
                        Ouput VGDL game file
  -lo LEVELOUTPUT,  --levelOutput LEVELOUTPUT
                        Ouput VGDL level file
  -vh, --verboseHelp    Show additional information

Planning with Siadex

The HTN planner can be found in the planners/Siadex directory.

Syntax: ./planner/planner [options] --domain_file (-d) <domain.pddl> --problem_file 
(-p) <problem.pddl>

Options:
        --help (-h):                      Shows this screen.
        --debug (-g):                     Runs the planner on debug mode.
        --verbose (-v[<level>] i.e: -v1): Sets on the verbose mode (1,2 o 3) (default 2).
        --output_file (-o) {filename}:    Writes resulting plan in a plain text file.
        --xml_file (-x) {filename}:       Writes resulting plan in xml format.
        --expansions_limit <number> :     Maximun number of allowed expansions.
        --depth_limit <number> :          Maximun depth during expansions.
        --time_limit <number> :           Maximun time of execution, in seconds.
        --seed (-s) <number> :            Random seed.

Replanning module

NOTE: Only works on Linux

The replanning module is defined as a GVGAI agent, located here. It uses a version of the GVGAI framework, from the official repo.

The agent is available for the games Sokoban (id=87), Brainman (id=12), Aliens (id=0) and Boulderdash (id=83). The levels ids ranges from 0 to 4.

A basic configuration file is included under the replanning folder, where you can specify the game and the level to test.

 

To run the agent, set the game id ant the level on replanning/configuration.txt and launch the java class /master/replanning/GVGAI/src/tracks/singlePlayer/Test.java

You can also use an already defined domain setting the KEEPDOMAIN variable in /master/replanning/GVGAI/src/main/Agent.java:20 as true and including it in the replanning/tmp folder with the name domain.hpdl.

📚 Results and experimentation

All related documentation and experimentation can be found under the doc directory.