0

我正在尝试使用 PDDL 用规划器解决 Pacman 风格的问题。我假设给定地图中有很多食物。我exists用来检查地图上是否还有其他食物,但它不起作用;这是为什么?

这是我的问题文件:

(define
    (problem pacman-level-1)
    (:domain pacman_simple)

;; problem map
;;  | 1 | 2 | 3 |
;; -|---|---|---|
;; a| P | G | F | 
;; b| _ | _ | _ | 
;;  |---|---|---| 

    (:objects
        a1 a2 a3 b1 b2 b3 - cell
        pacman - pacman
        ghost - ghost
        food1 - food
        food2 - food
        nofood - nofood
    )

    (:init
        (at a1 pacman)
        (at a2 ghost)
        (status a1 nofood)
        (status a2 nofood)
        (status a3 food1)
        (status b1 nofood)
        (status b2 nofood)
        (status b3 food2)
        (adjacent a1 a2) (adjacent a1 b1)
        (adjacent a2 a1) (adjacent a2 b2) (adjacent a2 a3)
        (adjacent a3 a2) (adjacent a3 b3)
        (adjacent b1 a1) (adjacent b1 b2)
        (adjacent b2 b1) (adjacent b2 a2) (adjacent b2 b3)
        (adjacent b3 b2) (adjacent b3 a3)
        (same a1 a1)
        (same a2 a2)
        (same a3 a3)
        (same b1 b1)
        (same b2 b2)
        (same b3 b3)
    )

    (:goal
        (and
            (eatallfood)
        )

    )
)

以下是我的域文件:

(define
    (domain pacman_simple)
    (:requirements :strips :typing :equality :adl :conditional-effects)

    (:types
        cell subject - object
        pacman ghost - subject
        food nofood - cellstatus
    )
    (:constants 
        F - food
        NF - nofood
    )
    (:predicates
        (adjacent  ?c - cell ?c - cell)
        (at ?c - cell ?s - subject)
        (status ?c - cell ?s - cellstatus)
        (eatallfood)
        (same ?c1 ?c2 - cell)
    )

    (:action move
        :parameters (?from - cell ?to - cell ?p - pacman ?g - ghost ?nf - nofood ?f - food)
        :vars
            (
                ?x - food
            )
        :precondition 
            (and

                (adjacent ?from ?to)
                (at ?from ?p)

                (status ?from ?nf)

                (not
                    (at ?to ?p)
                )
                (not
                    (at ?to ?g)
                )
                (not
                    (eatallfood)
                )

            )
        :effect
            (and
                (at ?to ?p)
                (status ?to ?nf)
                (not
                    (at ?from ?p)
                )

                (when (not 
                            (exists (?c - cell) 
                                    (and 
                                        (and
                                            (not (same ?to ?c))
                                            (status ?c ?f)
                                        )

                                    )
                            )
                      )
                      (and
                            (eatallfood)
                      )
                )
            )
    )
)

错误信息:ff: 目标可以简化为 FALSE。没有计划能解决它

4

1 回答 1

1

我认为问题在于您对 的使用when,FastForward 可能无法处理。您可以尝试在没有它的情况下重新表述您的问题。

你有六个细胞。只需引入一个 predicate (food <cell>),您最初将其设置为 true ,如

(food a1) (food a2) ...

移动的效果将是(not (food ?to)),即该单元格中的食物被移除。然后你需要重新表述你的目标

(and (not (food a1)) (not (food a2)) ...)

那不太优雅,但应该可以解决问题。

move操作应该如下所示:

(:action move
 :parameters (?from - cell ?to - cell ?p - pacman ?g - ghost)
 :precondition (and
     (adjacent ?from ?to)
     (at ?from ?p)
     (not (at ?to ?g)))
 :effect (and
     (at ?to ?p)
     (not (at ?from ?p))
     (not (food ?to))))
于 2020-04-30T19:14:02.027 回答