pddl - PDDL 谓词名称必须是字符串
问题描述
我正在尝试使用 pddl 解决计划任务,并且我编写了以下域
(define (domain Monster)
(:requirements :strips)
(:predicates (player ?p) (location ?x) (monster ?m) (treasure ?tr) (trap ?tp) (weapon ?w) (flyer ?f) ;entities
(playerat ?player ?location) (monsterat ?monster ?location) (trapat ?trap ?location) (treasureat ?trasure ?location) (weaponat ?weapon ?location) (flyerat ?flyer ?location); relations
(gameOver ?p) (holdsw ?p) (holdsf ?p) (holdst ?p) (go ?A ?B) (close ?A ?B)
)
(:action Move ;Move from location A to location B
:parameters (?P ?A ?B ?M) ; P->Player A->Location_1 B->Location_2
:precondition (and(player ?P) (location ?A) (location ?B) (monster ?M) (playerat ?P ?A) (go ?A ?B) (not(monsterat ?M ?B)) )
:effect (and(playerat ?P ?B) (not(playerat ?P ?A)) )
)
(:action PickWeapon ; picking up weapon
:parameters (?P ?L ?W) ;P->player L->location W->Weapon
:precondition (and(player ?P) (location ?L) (weapon ?W) (playerat ?P ?L) (weaponat ?W ?L) )
:effect (and(holdsw ?P) (not(weaponat ?W ?L)))
)
(:action PickFlyer ;picking up flyer
:parameters (?P ?L ?F) ;P->player L->location F->flyer
:precondition (and(player ?P) (location ?L) (flyer ?F) (playerat ?P ?L) (flyerat ?F ?L) )
:effect (and(holdsf ?P) (not(flyerat ?F ?L)) )
)
(:action PickTreasure ;picking up treasure
:parameters (?P ?L ?T) ;P->player L->location T->treasure
:precondition (and(player ?P) (location ?L) (treasure ?T) (playerat ?P ?L) (treasureat ?T ?L) )
:effect (and(holdst ?P) (not(treasureat ?T ?L)) )
)
(:action PlayerKilled ;player killed
:parameters (?P ?L ?M) ;P->player L->location M->monster
:precondition (and(player ?P) (location ?L) (monster ?M) (playerat ?P ?L) (monsterat ?M ?L) (not(holdsw ?P)) (not(holdsf ?P)) )
:effect (and(gameOver ?P) (not(playerat ?P ?L)) ); Game Over
)
(:action PlayerTraped ;Player traped
:parameters (?P ?L ?TR) ;P->player L->location TR->trap
:precondition (and(player ?P) (location ?L) (trap ?TR) (playerat ?P ?L) (trapat ?TR ?L) (not(holdsf ?P)) )
:effect (and(gameOver ?P) (not(playerat ?P ?L)) )
)
(:action Kill ;Killing Monster
:parameters (?P ?A ?M ?B) ;P->player L->location M->monster
:precondition (and(player ?P) (location ?B) (location ?A) (monster ?M) (playerat ?P ?A) (monsterat ?M ?B) (holdsw ?P) (close ?A ?B) (go ?A ?B) )
:effect (and(playerat ?P ?B) (not(monsterat ?M ?B)) (not(holdsw ?P)) )
)
(:action FlyOverMonster
:parameters (?P ?F ?L ?A ?M) ;P->player L->location F->flyer M->monster
:precondition (and(player ?P) (location ?L) (location ?A) (monster ?M) (playerat ?P ?A) (monsterat ?M ?L) (holdsf ?P) (close ?A ?L) (go ?A ?L) )
:effect (and(playerat ?P ?L) (not(holdsf ?P)) )
)
(:action FlyOverTrap
:parameters (?P ?F ?L ?A ?TR) ;P->player L->location F->flyer TR->trap
:precondition (and(player ?P) (location ?L) (location ?A) (trap ?TR) (playerat ?P ?A) (trapat ?TR ?L) (holdsf ?P) (close ?A ?L) (go ?A ?L) )
:effect (and(playerat ?P ?L) (not(holdsf ?P)) )
)
)
问题 我将要计划的问题定义如下
(define (problem Monster2)
(:domain Monster)
(:objects a b c d e f g h i pl mo tp fl tr wp
)
(:init
(location a) (location b) (location c) (location d) (location e) (location f) (location g) (location h) (location i)
(player pl) (monster mo) (trap tp) (flyer fl) (treasure tr) (weapon wp)
(go a b) (go b a) (go b c) (go c b) (go c d) (go d c) (go a e) (go e b) (go e f) (go f d) (go e g) (go e h) (go h e) (go h i) (go i h)
(close b c) (close c d) (close e f)
(playerat pl a) (monsterat mo c) (treasureat tr d) (trapat tp f) (weaponat wp h) (flyerat fl i)
)
(:goal (and
(holdst pl)
(playerat pl a)
)
)
)
试图解决这个问题我改变了我的代码,但现在我面临另一个问题。杀死怪物后的特工没有去下一个房间,而是返回然后侧柱到d房间收集宝藏并留在d。奇怪的是,刨床说代理现在在房间 c,而在下一个状态它说他在房间 b。
Planner 结果
Planer Kill Monster agent at room c
解决方案
实际上,PDDL 文件中有几个错误。我用FF测试过。
在域文件中,您在不同的操作定义中错过了一些 AND 和几个括号,例如
(:action Kill
:parameters (?P ?L ?M ?A) ;P->player L->location M->monster
:precondition (and(player ?P) (location ?L) (location ?A) (monster ?M) (atp ?P ?A) (atm ?M ?L) (holdsw ?P ?W) (close ?A ?L) )
:effect (and (not(atm ?M ?L)) (not(holdsw ?P ?W)) (atp ?P ?L))
)
然后你忘了声明域定义中使用的一些谓词,例如 at1...at6,位于
然后在动作FlyOverMonster和FlyOverTrap中,您忘记在动作Kill和PlayerKilled中声明变量 ?A、变量 ?W 。
在行动 PlayerKilled 中,您有一个不会出现在其他任何地方的谓词保持。
我不继续,但我希望更正清楚。然后,计划者应该指出它遇到的错误类型。
推荐阅读
- python - 更改在熊猫中矢量化的这一行和上一行
- python - 尽管版本控制正确,但无法从“tensorflow.python.keras.engine”导入名称“keras_tensor”
- eclipse - Gradle Daemon 似乎启动了多个 java exe
- git - 如何让 github 操作工作流使用机器人名称将生成的文档推送到同一组织中的其他存储库
- python - 打开串行端口连接问题 - 找不到端口路径(Windows)
- python - 什么可能导致我的程序在一个函数上运行两次,即使它应该在运行一次后退出?
- java - 如果之前已经完成,为什么在检查两个字符时需要增加/减少两个索引?
- php - PHP根据当前数组键取消移位和推送值
- azure - 如何从 Azure DevOps 触发 AzureML 管道?
- java - 春季启动验证 - 至少一个交叉字段