我是 PDDL 新手,很难理解它是如何工作的。带着这个问题,我有兴趣知道问题是否与语法、边缘情况有关,或者只是我对 PDDL 的理解错误。特别是以下内容:当我使用 when 子句检查条件时,它会改变谓词吗?在下面的示例中,当我检查 (light-on ?room) 时,它是否会将 light-on 谓词切换为 True 值?如果是的话如何编码这样的效果?
这是问题的领域:
(define (domain vampire)
(:requirements :conditional-effects)
(:predicates
(light-on ?r)
(slayer-is-alive)
(slayer-is-in ?r)
(vampire-is-alive)
(vampire-is-in ?r)
(fighting)
;
; static predicates
(NEXT-ROOM ?r ?rn)
(CONTAINS-GARLIC ?r)
)
(:action toggle-light
:parameters (?anti-clockwise-neighbor ?room ?clockwise-neighbor)
:precondition (and
(NEXT-ROOM ?anti-clockwise-neighbor ?room)
(NEXT-ROOM ?room ?clockwise-neighbor)
(not (fighting))
)
:effect (and
(when
(and (not(light-on ?room)) (vampire-is-in ?room) (not(light-on ?clockwise-neighbor)))
(and (light-on ?room) (not(vampire-is-in ?room)) (vampire-is-in ?clockwise-neighbor))
)
(when
(and (not(light-on ?room)) (vampire-is-in ?room) (not(light-on ?anti-clockwise-neighbor)))
(and (light-on ?room) (not(vampire-is-in ?room)) (vampire-is-in ?anti-clockwise-neighbor))
)
(when
(and (not(light-on ?room)) (vampire-is-in ?room) (not(light-on ?anti-clockwise-neighbor)) (not(light-on ?clockwise-neighbor)) )
(and (light-on ?room) (not(vampire-is-in ?room)) (vampire-is-in ?anti-clockwise-neighbor))
)
(when
(and (not(light-on ?room)) (vampire-is-in ?room) (light-on ?anti-clockwise-neighbor) (light-on ?clockwise-neighbor))
(and (light-on ?room) (not(vampire-is-in ?room)) (vampire-is-in ?clockwise-neighbor))
)
;;
;;
(when
(and (light-on ?room) (slayer-is-in ?room) (light-on ?clockwise-neighbor))
(and (not (light-on ?room)) (not(slayer-is-in ?room)) (slayer-is-in ?clockwise-neighbor))
)
(when
(and (light-on ?room) (slayer-is-in ?room) (not(light-on ?clockwise-neighbor)))
(and (not (light-on ?room)) (not(slayer-is-in ?room)) (slayer-is-in ?anti-clockwise-neighbor))
)
)
)
(:action watch-fight
:parameters (?room)
:precondition (and
(slayer-is-in ?room)
(slayer-is-alive)
(vampire-is-in ?room)
(vampire-is-alive)
(fighting)
)
:effect (and
(when
(CONTAINS-GARLIC ?room)
(not(vampire-is-alive))
)
(when
(light-on ?room)
(not(vampire-is-alive))
)
(when
(not(light-on ?room))
(not(slayer-is-alive))
)
)
)
)
这是一个可能的问题:
(define (problem p01)
(:domain vampire)
;
; Room1 Room2 Room3 Room4 Room5
; 1S 0 1 0G 0V
;
(:objects
room1
room2
room3
room4
room5
)
(:init
(light-on room1)
(light-on room3)
(slayer-is-alive)
(slayer-is-in room1)
(vampire-is-alive)
(vampire-is-in room5)
(CONTAINS-GARLIC room4)
(NEXT-ROOM room1 room2)
(NEXT-ROOM room2 room3)
(NEXT-ROOM room3 room4)
(NEXT-ROOM room4 room5)
(NEXT-ROOM room5 room1)
)
(:goal (and
(slayer-is-alive)
(not (vampire-is-alive))
(slayer-is-in room3)
))
)
谢谢你
条件效果都是以下形式……
(when <cond> <eff>)
…其中
<cond>
可以是流利词或流利词的合词或类似的东西,并且 <eff>
类似地是流词或流词的合词。当您在状态 s
中执行操作并进入状态 s’
时,解释条件效果的方法是:“当 <cond>
保持在状态 s
时,那么 <eff>
应该保持在状态 s’
”。
有一些额外的细节(析取和存在在条件中可以,但在效果中不行,如果有多个条件效果触发,则添加效果优先,等等),但这是一般过程。要记住的重要一点是,
<cond>
仅指状态s
中可能保持的内容,而<eff>
描述将要发生的变化。