2

我正在尝试使用 PDDL 解决 Pacman 问题。我需要做的主要事情是在不使用functionsor的情况下对电源持续时间进行软编码fluents。它没有返回错误,但不知何故我觉得它 inits Powerlose(n2, n0)。我从不初始化Powerlose(n2, n0)或改变Powerlose效果。但它赋予的初始c值为n2。那么有什么问题呢?提前致谢。

您可以通过此链接检查问题和域:http: //editor.planning.domains/#edit_session=bD5G0tIIl1vyWDf

我尝试使用exists语句而不是Powerlose(cPlus1, c)域文件的第 34 行,它不起作用。它仍然cn2. 我感到很困惑。这是我的域文件:

(define
    (domain pacman_hard)
    (:requirements :strips :typing :equality :adl)

    (:types
       pos int
    )

    (:predicates
        (PacmanAt ?p - pos)
        (GhostAt ?p - pos)
        (FoodAt ?p - pos)
        (CapsuleAt ?p - pos)
        (PowerCurr ?n - int)
        (PowerLose ?n1 ?n2 - int)
        (PowerGain ?n1 ?n2 - int)
        (Adjacent ?p1 ?p2 - pos)
    )


    (:action move
        :parameters (?posCurr ?posNext - pos ?cPlus1 ?c ?MaxPower - int)
        :precondition (and
                        (and
                        ; check if there is any food left,
                        ; which guarantees all ghosts are eaten before last food
                        (exists (?p - pos) (FoodAt ?p)) 
                        (PacmanAt ?posCurr)
                        (Adjacent ?posCurr ?posNext)
                        (PowerCurr ?cPlus1)
                        (PowerGain ?cPlus1 ?MaxPower)
                        )
                        (or
                        (PowerLose ?cPlus1 ?c) ;powered
                        (not (GhostAt ?posNext))
                        )
                      )
        :effect (and 
                    (PacmanAt ?posNext)
                    (not (PacmanAt ?posCurr))
                    ; update power status accordingly/with priority
                    ; first reduce the time of power
                    (when (PowerLose ?cPlus1 ?c); could minus 1  
                        (and
                        (not (PowerCurr ?cPlus1))
                        (PowerCurr ?c)
                        (not (GhostAt ?posNext))
                        )
                    )

                    ; refresh the power time if in next pos its a capsule
                    (when (CapsuleAt ?posNext)
                        (and
                        (not (PowerCurr ?cPlus1))
                        (not (PowerCurr ?c))
                        (PowerCurr ?MaxPower)
                        )
                    )
                    (not (FoodAt ?posNext))
                    (not (CapsuleAt ?posNext))
                )
    )
)

问题文件:

  problem map
 | 1 | 2 | 3 | 4 | 5 |
-|---|--- ---|---|---|
a| P | _ | _ | G | F |
b| _ | C | _ | G | C |
 |---|---|---|---|---|





(define
    (problem pacman-level-1)
    (:domain pacman_hard)
    (:objects
        a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 - pos
        n0 n1 n2 - int
    )

    (:init
        (PacmanAt a1)
        (GhostAt a4)
        (GhostAt b4)
        (CapsuleAt b2)
        (CapsuleAt b5)
        (FoodAt a5)

        (PowerCurr n0)
        (PowerLose n1 n0)
        (PowerLose n2 n1)

        (PowerGain n0 n2)
        (PowerGain n1 n2)
        (PowerGain n2 n2)


        (Adjacent a1 a2)
        (Adjacent a1 b1)
        (Adjacent b1 a1)
        (Adjacent b1 b2)
        (Adjacent a2 a1)
        (Adjacent a2 b2)
        (Adjacent a2 a3)
        (Adjacent b2 a2)
        (Adjacent b2 b1)
        (Adjacent b2 b3)
        (Adjacent a3 a2)
        (Adjacent a3 b3)
        (Adjacent a3 a4)
        (Adjacent b3 b2)
        (Adjacent b3 a3)
        (Adjacent b3 b4)
        (Adjacent a4 a3)
        (Adjacent a4 b4)
        (Adjacent a4 a5)
        (Adjacent b4 b3)
        (Adjacent b4 a4)
        (Adjacent b4 b5)
        (Adjacent a5 a4)
        (Adjacent a5 b5)
        (Adjacent b5 b4)
        (Adjacent b5 a5)
    )

    (:goal
        ; this would guarantee the pacman has eaten all food and ghosts.
        (forall (?p - pos) 
            (and (not (FoodAt ?p)) (not (GhostAt ?p))) 
        )
    )
)

它返回的计划: (move a1 b1 n0 n2 n2) (move b1 b2 n0 n2 n2) (move b2 b3 n2 n2 n2) (move b3 b4 n2 n1 n2) (move b4 a4 n1 n0 n2) (move a4 a5 n0 n2 n2)

正确的计划: (move a1 b1) (move b1 b2) (move b2 b3) (move b3 b4) (move b4 b5) (move b5 b4) (move b4 a4) (move a4 a5)

4

1 回答 1

2

顺便说一句,指定您正在使用的计划器(及其配置)总是有用的。

我将您的问题加载到在线编辑器中:

当我尝试解决时,它给出了一个类似的计划(至少是计划的开始)。我建议做同样的事情(解决按钮在顶部),并查看计划。右侧显示接地动作。首先要注意的是,您的Powerlose先决条件是or子句的一部分,而另一部分肯定满足(即为(ghostat b1)假)。所以前提条件的那个方面是满足的。

希望这可以弄清楚可能发生的事情!

于 2020-05-01T13:25:04.733 回答