PDDL谓词名称必须是字符串

  • 本文关键字:字符串 谓词 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房间。

策划师结果
策划师杀死怪物特工在房间c

计划器结果Planner移动下一个应该是d房间,它说b房间的状态是错误的

实际上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,位于

然后在操作FlyOverMonsterFlyOverTrap中,您忘记声明变量了吗?A、 变量?W在击杀玩家击杀中。

在动作PlayerKilled中,你有一个谓词hold,它不会出现在其他地方。

我不继续了,但我希望更正是清楚的。然后,规划者应该指出它遇到的错误类型。

检查谓词名称,我不确定它们的名称和参数名称中是否支持数字。在你的问题中,我可以看到at1at2等的出现……这些谓词的名称很奇怪,我怀疑它是否有效。此外,它们不会在您的域中声明。

最新更新