About PDDL in AI planning

独自空忆成欢 提交于 2021-02-11 17:23:58

问题


I am trying to solve a Pacman-style problem with a planner, using PDDL. I assume there are many food in the given map. I use exists to check if here is any other food in the map, but it does not work; why is that?

Here is my problem file:

(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)
        )

    )
)

and the following is my domain file:

(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)
                      )
                )
            )
    )
)

error message: ff: goal can be simplified to FALSE. No plan will solve it


回答1:


I think the problem is your use of when, which FastForward might not be able to deal with. You could try rephrasing your problem without it.

You have six cells. Just introduce a predicate (food <cell>), which you set to true initially, as in

(food a1) (food a2) ...

The the effect of moving would be (not (food ?to)), ie the food in that cell gets removed. You then need to rephrase your goal to

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

That is less elegant, but should do the trick.

The move action should probably look like this:

(: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))))


来源:https://stackoverflow.com/questions/61530151/about-pddl-in-ai-planning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!