Blocks-world PDDL Python

Getting started

The framework is released as EGG file to be used on a Desktop platform, therefore it can be easily installed in a Python installation.

The framework needs ANTLR4 library for its operation.

Using EmbASP

In the following, we describe an actual usage of the framework by means of a running example; as a use case, we will develop a simple Desktop application to solve the blocks-world problem.

The complete code of this example is freely available here.


We will make use of the annotation-guided mapping, in order to retrieve the actions constituting a PDDL plan via Python objects.

To this purpose, the following classes are intended to represent possible actions that a blocks-world solution plan can feature:

class PickUp(Predicate):

   def __init__(self, block=None):
      super(PickUp, self).__init__([("block")])
      self.block = block

class PutDown (Predicate):

   def __init__(self, block=None):
      super(PutDown, self).__init__([("block")])
      self.block = block

class Stack (Predicate):

   def __init__(self, block1=None, block2=None):
      super(Stack, self).__init__([("block1"), ("block2")])
      self.block1 = block1
      self.block2 = block2

class Unstack (Predicate):

   def __init__(self, block1=None, block2=None):
      super(Unstack, self).__init__([("block1"), ("block2")])
      self.block1 = block1
      self.block2 = block2


At this point, supposing that we are given two files defining the blocks-world domain and a problem instance, we can start deploying our application:

handler  = DesktopHandler(SPDDesktopService())

input_domain = PDDLInputProgram(PDDLProgramType.DOMAIN)

input_problem= PDDLInputProgram(PDDLProgramType.PROBLEM)



output = handler.start_sync()

for obj in output.get_actions_objects():
   if isinstance(obj, PickUp) | isinstance(obj, PutDown) | isinstance(obj, Stack) | isinstance(obj, Unstack) :

The file contains an Handler instance as field, that is initialized with a DesktopHandler using the required parameter SPDDesktopService.

Then it’s set-up the input to the solver; since PDDL requires separate definitions for domain and problem, two PDDLInputProgram are created and then given to the handler.

The next lines inform the PDDLMapper about what classes are intended to map the output actions.

Finally the solver is invoked, and the output is retrieved.

The output actions can be managed accordingly to the user’s desiderata.

For further information, contact or visit our website.