I'm learning how to use PDDL for a IA class and I have to code a plan where I need to pick a person up from location4 and drop it in location1, also pick a person in location3 and drop it in location1 also. I already have the code which move to location pick the person, move to destiny location and drop it. but there are some rules that I can't put on code, there is a connection path that I need to follow and I do not know how to put that conditions:
This is the connection path: Loction1 -> Location2 -> Location4 -> Location3
I have the code to go from one location to other but I do not know how to put a condition in where it can't go from Location 1 to Location 4 directly
Here is the code:
Domain:
(define (domain planeacion_Str)
(:predicates (Hospital ?h)
(Ambulancia ?a)
(Location ?l)
(Paciente ?px)
(Libre ?a)
(Ocupado ?a ?px)
(at-ambulancia ?l)
(at-paciente ?px ?l)
)
(:action Conducir
:parameters (?de ?para)
:precondition (and (Location ?de) (Location ?para) (at-ambulancia ?de))
:effect (and (at-ambulancia ?para)
(not (at-ambulancia ?de)))
)
(:action subirPaciente
:parameters (?pcte ?lctn ?amblnc)
:precondition (and (Paciente ?pcte) (Location ?lctn) (Ambulancia ?amblnc)
(at-paciente ?pcte ?lctn) (at-ambulancia ?lctn) (Libre ?amblnc))
:effect (and (Ocupado ?pcte ?amblnc)
(not (at-paciente ?pcte ?lctn))
(not (Libre ?amblnc)))
)
(:action bajarPaciente
:parameters (?pcte ?lctn ?amblnc)
:precondition (and (Paciente ?pcte) (Location ?lctn) (Ambulancia ?amblnc)
(Ocupado ?pcte ?amblnc) (at-ambulancia ?lctn))
:effect (and (at-paciente ?pcte ?lctn)
(Libre ?amblnc)
(not (Ocupado ?pcte ?amblnc)))
))
(define (problem practica_Planeacion_pblm) (:domain planeacion_Str) (:objects l1 l2 l3 l4 amblnc px1 px2 hospital) (:init (Hospital l1) (Ambulancia amblnc) (Location l1) (Location l2) (Location l3) (Location l4) (Paciente px1) (Paciente px2) (Libre amblnc) (at-ambulancia l1) (at-paciente px1 l4) (at-paciente px2 l3) ) (:goal (and (at-paciente px1 l1) (at-paciente px2 l1) ) ) )
Hope someone can help me.
You need to add a precondition to your movement action that you can only move between adjacent locations; and you then add a list of adjacent locations as predicates in your initial state:
(adjacent location1 location2)
(adjacent location2 location3)
but not (adjacent location1 location4)
.