0

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

Oliver Mason
  • 2,240
  • 2
  • 15
  • 23
yi li
  • 1
  • 1
  • I don't have the time to fully diagnose, but the error message you're seeing almost always comes from an unsolvable instance that is trivial for the planner to detect. The best way to test this out is to follow the following strategy: (1) write down a plan you know will solve it; (2) starting with the first action, set the goal to the precondition; (3) repeat to the end. If that fails, start changing the initial state to what you expect the complete state to be during the execution of the plan. – haz May 01 '20 at 02:04

1 Answers1

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))))
Oliver Mason
  • 2,240
  • 2
  • 15
  • 23