Я пытаюсь решить проблему Пакмана с помощью PDDL. Главное, что мне нужно сделать, это программно кодировать длительность питания без использования functions
или fluents
. Это не возвращает ошибку, но почему-то я чувствую, что это inits Powerlose(n2, n0)
. Я никогда не инициирую Powerlose(n2, n0)
или не изменяю Powerlose
в эффекте. Но начальное значение, которое оно дает c
, равно n2
. Так что не так? Заранее спасибо.
Вы можете проверить проблему и домен по этой ссылке: http://editor.planning.domains/#edit_session = bD5G0tIIl1vyWDf
Я пытался использовать оператор exists
вместо Powerlose(cPlus1, c)
в строке 34 файла домена он не работает. Это все еще init c
с n2
. Я так растерялся. Вот мой файл домена:
(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)))
)
)
)
План, который он возвращает: (переместить a1 b1 n0 n2 n2) (переместить b1 b2 n0 n2 n2) ( ход b2 b3 n2 n2 n2) (ход b3 b4 n2 n1 n2) (ход b4 a4 n1 n0 n2) (ход a4 a5 n0 n2 n2)
правильный план: (ход a1 b1) (ход b1 b2 ) (ход b2 b3) (ход b3 b4) (ход b4 b5) (ход b5 b4) (ход b4 a4) (ход a4 a5)