我被要求为著名的“山羊、狼和卷心菜”场景写一个解决方案。场景如下:
农夫想把这三个人都运过河。但是,如果:
- 山羊和白菜一个人呆着,山羊会吃白菜
- 如果狼和山羊一个人呆着,狼会吃掉山羊!
因此,该问题的一种解决方案如下:
- 把山羊带过河,然后把它扔到另一边
- 过河回来
- 拿起卷心菜或狼,把它带到另一边
- 放下狼,捡起山羊,然后回到另一边
- 放下山羊,拿起卷心菜,然后回到另一边
- 拿起山羊,瞧!这三个都被运输了。
但是,我无法将其投影到 PDDL 中。我已经给出了问题定义:
(define
(problem boat1)
(:domain boat)
; only needs two objects, namely representing
; either banke side of the river, [w]est and [e]ast
(:objects w e)
(:INIT
; wolf, goat, cabbage, boat are all on
; the west side to start with
(config w w w w)
; represent all valid states
; these two are the special case,
; representing that wolf and cabbage are
; safe together even if the boat is away
(valid w e w e)
(valid e w e w)
; these are all cases where two entities
; are always safe as long as the boat is
; with them. In other words, a single entity
; on the other side is also always safe
; for west side
(valid w w w w)
(valid w w e w)
(valid w e w w)
(valid e w w w)
; for east side
(valid e e e e)
(valid e e w e)
(valid e w e e)
(valid w e e e)
; these are all valid states that are
; ever allowed
)
(:goal (AND
; they all have to move to the east side
(config e e e e)
)
)
最后,我们只得到了 1 个谓词,并被告知这可以通过 4 个动作来完成。move_empty,move_goat,move_wolf,move_cabbage。
谓词是:
(配置?狼?山羊?卷心菜?船)(有效?狼?山羊?卷心菜?船)
我试图从 move_empty 开始:
(:action move_empty
:parameters (?from ?to)
:precondition (and (valid ?x ?y ?z ?w) (on_left ?from) (on_right ?to))
:effect (and (valid ?x ?y ?z ?w)))
我不希望得到答案,只希望得到关于如何解决这个问题的帮助和建议,因为我能找到的关于 PDDL 的信息并不多。