(define (domain dungeon_hero)
(:requirements :strips :adl :typing :negative-preconditions) ;; There is use of negative-preconditions in the domain
(:types hero room sword monster trap clear) ;; Various types used
(:predicates (connected ?r1 -room ?r2 -room) ;; defines that two rooms are connected and will be defined twice for bi-directional connection
(at-hero ?h -hero ?r -room) ;; defines what is there in which room i.e.hero,trap,monster or room is clear
(monster-in ?m -monster ?r1 -room) ;; defines a monster in a room
(trap-in ?t -trap ?r -room) ;; defines a trap in a room
(sword-in ?s -sword ?r -room) ;; defines a sword in a room
(clear-room ?r -room) ;; defined a room is clear
(handempty ?h -hero ) ;; TRUE if the Hero's hand is empty
(haveSword ?s -sword ) ;; if the hero is holding the sword
(alive ?h -hero) ;; If the hero is alive
(exist ?r -room) ;; If the room is not destroyed i.e. after the visit
)
(:action visit2sword
:parameters (?h -hero ?from -room ?to -room ?s -sword ?t -trap ?m -monster)
:precondition (and (at-hero ?h ?from)(alive ?h) (exist ?to)(sword-in ?s ?to)(connected ?from ?to) )
:effect
(and (not (at-hero ?h ?from))
(not(exist ?from))
(at-hero ?h ?to)
(not(monster-in ?m ?to))
(not(trap-in ?t ?to))
)
)
(:action pick-up-sword
:parameters (?h -hero ?r -room ?s -sword )
:precondition (and (at-hero ?h ?r)(alive ?h) (sword-in ?s ?r) (handempty ?h))
:effect
(and (not (handempty ?h))
(haveSword ?s)
(not(sword-in ?s ?r))
)
)
(:action visit2monster
:parameters (?h -hero ?from -room ?to -room ?s -sword ?m -monster ?t -trap)
:precondition (and (at-hero ?h ?from)(alive ?h)(not(handempty ?h))(exist ?to)(haveSword ?s)(monster-in ?m ?to) (connected ?from ?to) )
:effect
(and (not (at-hero ?h ?from))
(not(exist ?from))
(at-hero ?h ?to)
(not(trap-in ?t ?to))
(not(sword-in ?s ?to))
)
)
(:action visit2trap
:parameters (?h -hero ?from -room ?to -room ?s -sword ?t -trap)
:precondition (and (at-hero ?h ?from)(alive ?h)(not(haveSword ?s))(handempty ?h)(trap-in ?t ?to) (exist ?to)(connected ?from ?to) )
:effect
(and (not (at-hero ?h ?from))
(not(exist ?from))
(at-hero ?h ?to)
)
)
(:action visit2clear
:parameters (?h -hero ?from -room ?to -room ?s -sword ?t -trap ?m -monster)
:precondition (and (at-hero ?h ?from)(alive ?h)(clear-room ?to)(exist ?to)(connected ?from ?to) )
:effect
(and (not (at-hero ?h ?from))
(not(exist ?from))
(at-hero ?h ?to)
(not(monster-in ?m ?to))
(not(trap-in ?t ?to))
;; (not(sword-in ?s ?to))
)
)
(:action destroy-sword
:parameters (?h -hero ?t -trap ?s -sword ?m -monster ?r -room )
:precondition
((at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r)
;;(and(at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r))
)
:effect
(and (handempty ?h)
(not(haveSword ?s))
)
)
(:action disarm ;; Disarm the trap to
:parameters (?h -hero ?t -trap ?r -room )
:precondition (and(at-hero ?h ?r)(alive ?h)(handempty ?h)(trap-in ?t ?r) )
:effect
(and (not (trap-in ?t ?r))
)
)
(:action getkilled ;; Disarm the trap to
:parameters (?h -hero ?m -monster ?s -sword ?r -room )
:precondition (and(at-hero ?h ?r)(alive ?h)(handempty ?h)(monster-in ?m ?r)(not(haveSword ?s))) ;;
:effect
(and (not (alive ?h))
)
)
)
(define (problem T2PROBLEM-1)
(:domain dungeon_hero)
(:objects d0-1 d1-1 d1-2 d2-1 d2-2 d3-1 d3-2 d4-1 - room
sword1 - sword
mon1 mon2 - monster
clear1 clear2 - clear
trap1 - trap
h1 - hero
;;h1 -hand
)
(:INIT
;; Initial status of the hero h1
(at-hero h1 d0-1)
(alive h1)
(handempty h1)
;; content of each room
(sword-in sword1 d1-1)
(monster-in mon1 d1-2)
(monster-in mon2 d2-1)
(trap-in trap1 d1-1)
(clear-room d2-2)
(clear-room d3-2)
(clear-room d4-1)
;; All rooms exist at the initial state and hence exist should be TRUE
(exist d0-1) (exist d1-1) (exist d1-2) (exist d2-1) (exist d2-2)
(exist d3-1) (exist d3-2) (exist d4-1)
;; Rooms are connected in both direction being undirected graph
(connected d0-1 d1-1)(connected d1-1 d0-1)
(connected d0-1 d1-2)(connected d1-2 d0-1)
(connected d1-1 d1-2)(connected d1-2 d1-1)
(connected d1-1 d2-1)(connected d2-1 d1-1)
(connected d1-2 d2-2)(connected d2-2 d1-2)
(connected d2-1 d2-2)(connected d2-2 d2-1)
(connected d2-1 d3-1)(connected d3-1 d2-1)
(connected d2-2 d3-2)(connected d3-2 d2-2)
(connected d3-1 d3-2)(connected d3-2 d3-1)
(connected d3-1 d4-1)(connected d4-1 d3-1)
)
(:goal (AND (ALIVE h1) (AT-hero h1 d4-1)))
)
Asked
Active
Viewed 145 times
0

Oliver Mason
- 2,240
- 2
- 15
- 23

Bil
- 11
- 2
-
Can you clarify your actual question? – Oliver Mason Jun 03 '20 at 17:37
-
It fails to find a plan – Bil Jun 03 '20 at 23:16
1 Answers
0
Your domain model is not valid PDDL.
Action "destroy-sword" has an "incorrect" precondition specification.
:precondition
((at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r)
;;(and(at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r))
)
Should this precondition be as follows?
:precondition
(and (at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r)
;;(and(at-hero ?h ?r)(alive ?h) (haveSword ?s)(not(monster-in ?m ?r)) (not(trap-in ?t ?r))
))
If you specify it as described above, the output of the planner is " ff: goal can be simplified to FALSE. No plan will solve it". So the specified planning problem has no plan.

David Speck
- 83
- 8