Skip to content

Small JavaScript PDDL parser

Notifications You must be signed in to change notification settings

simon-andrews/pddl-compiler-ish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDDL Compiler… ish

JavaScript parser for some of PDDL. Possibly more exciting stuff coming soon.

Basically, this program takes PDDL files in, and returns a representation of the program as a bunch of JavaScript objects (see src/pddl.js).

For example, something like

(define (domain repair-robot)
  (:predicates (is-broken ?x))
  (:action repair
    :parameters   (?thing1 ?thing2)
    :precondition (and (is-broken ?thing-1)
                       (is-broken ?thing-2))
    :effect       (and (not (is-broken ?thing1)
                            (is-broken ?thing2)))))

(define (problem repair-four-things)
  (:domain  repair-robot)
  (:objects toy vacuum-cleaner sink sculpture)
  (:init    (is-broken toy) (is-broken vacuum-cleaner)
            (is-broken sink) (is-broken sculpture))
  (:goal    (and (not (is-broken toy)
                      (is-broken vacuum-cleaner)
                      (is-broken sink)
                      (is-broken sculpture)))))

might parse to

[ Domain {
    name: 'repair-robot',
    predicates:
     [ Predicate { name: 'is-broken', variables: [ Variable { name: 'x' } ] } ],
    actions:
     [ Action {
         name: 'repair',
         parameters: [ Variable { name: 'thing1' }, Variable { name: 'thing2' } ],
         precondition:
          And {
            predicates:
             [ Predicate {
                 name: 'is-broken',
                 variables: [ Variable { name: 'thing-1' } ] },
               Predicate {
                 name: 'is-broken',
                 variables: [ Variable { name: 'thing-2' } ] } ] },
         effect:
          And {
            predicates:
             [ Not {
                 predicates:
                  [ Predicate {
                      name: 'is-broken',
                      variables: [ Variable { name: 'thing1' } ] },
                    Predicate {
                      name: 'is-broken',
                      variables: [ Variable { name: 'thing2' } ] } ] } ] } } ] },
  Problem {
    name: 'repair-four-things',
    domainName: 'repair-robot',
    objects:
     [ Obj3ct { name: 'toy' },
       Obj3ct { name: 'vacuum-cleaner' },
       Obj3ct { name: 'sink' },
       Obj3ct { name: 'sculpture' } ],
    init:
     [ Predicate { name: 'is-broken', variables: [ 'toy' ] },
       Predicate { name: 'is-broken', variables: [ 'vacuum-cleaner' ] },
       Predicate { name: 'is-broken', variables: [ 'sink' ] },
       Predicate { name: 'is-broken', variables: [ 'sculpture' ] } ],
    goal:
     And {
       predicates:
        [ Not {
            predicates:
             [ Predicate { name: 'is-broken', variables: [ 'toy' ] },
               Predicate { name: 'is-broken', variables: [ 'vacuum-cleaner' ] },
               Predicate { name: 'is-broken', variables: [ 'sink' ] },
               Predicate { name: 'is-broken', variables: [ 'sculpture' ] } ] } ] } } ]

Requirements

Getting started

  1. npm install
  2. node index.js YOURFILE.pddl

References

About

Small JavaScript PDDL parser

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published