Rootie
Rootie

Reputation: 111

PDDL Unable to Compile - Car Driving

I am new to PDDL and I am currently learning how to simple program to make a car move forward from pt0pt0 to pt1pt1.

However, I encountered a compilation error when I tried to run it on the PDDL editor. Can an experienced coder advise me on whats wrong with my code? Much appreciated, thanks.

problem.pddl

(define (problem parking) 
 (:domain grid_world) 
(:objects agent1  - agent
 pt0pt0 pt0pt1 pt1pt1  - gridcell
 ) 
(:init (at pt0pt0 agent1) (forward_next pt0pt0 pt0pt1) (forward_next pt0pt1 pt1pt1)) 
(:goal (at pt1pt1 agent1)) 
) 

domain.pddl

(define (domain grid_world ) 
(:requirements :strips :typing) 
(:types car
agent - car
gridcell
) 
(:predicates (at ?pt1 - gridcell ?car - car) 
(forward_next ?pt1 - gridcell ?pt2 - gridcell) 
) 
(:action FOWARD
:parameters ( ?agent - car ?pt1 - gridcell ?pt2 - gridcell) 
:precondition (and (at ?pt1 ?agent)) 
:effect (and (not (at ?pt1 ?agent)) (forward_next ?pt1 ?pt2) (at ?pt2 ?agent))
) 
) 

Upvotes: 0

Views: 563

Answers (1)

Jan Dolejsi
Jan Dolejsi

Reputation: 1528

Whitespace is insignificant in PDDL, so the type inheritance in your : types declaration should be either

(:types
    car - object
    agent - car
    gridcell
)

Or just...

(:types
    agent - car
    gridcell
)

You essentially defined a cyclical dependency car agent - car.

After this modification, you would get this plan:

0.00100: (foward agent1 pt0pt0 pt1pt1)

That is probably not what you wanted, so as a quick observation, move the (forward_next ?pt1 ?pt2) from your action effect to the precondition. You will get this plan:

0.00100: (foward agent1 pt0pt0 pt0pt1)
0.00200: (foward agent1 pt0pt1 pt1pt1)

You can find the fixed (and formatted for readability) PDDL in this session: http://editor.planning.domains/#read_session=qrAGLXX9O1

Click Solve to try it.

Upvotes: 1

Related Questions