artificial-intelligence - PDDL AI 规划中的一个错误

标签 artificial-intelligence planning pddl

我正在尝试使用 PDDL 解决 Pacman 问题。我需要做的主要事情是在不使用函数或流利的情况下对功率持续时间进行软编码。它没有返回错误,但不知怎的,我感觉它初始化了Powerlose(n2, n0)。我从来没有初始化 Powerlose(n2, n0) 或更改效果中的 Powerlose 。但它赋予c的初始值为n2。那么出了什么问题呢?提前致谢。

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

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

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

最佳答案

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

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

当我尝试解决问题时,它给出了类似的计划(至少是计划的开始)。我建议做同样的事情(解决按钮位于顶部),并查看计划。右侧显示接地 Action 。首先要注意的是,您的 Powerlose 前提条件是 or 子句的一部分,并且另一部分肯定满足(即 (ghostat b1) 是假的)。因此这方面的先决条件得到满足。

希望这能澄清可能发生的事情!

关于artificial-intelligence - PDDL AI 规划中的一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61543046/

相关文章:

javascript - 是否有可能使网页(例如 HTML5 游戏)用 Javascript 模拟按键?

java - Python 中的分层任务网络规划器

artificial-intelligence - 如何在PDDL forall中获得break功能

规划工具的算法

C# 和 SWI-Prolog - 将字符列表转换为事实列表

parsing - 为什么我的PDDL不编译?解析错误

artificial-intelligence - 是否可以从 PDDL 实现中获得多个计划?

mysql - 如何获取 AI 的 mysql 查询?

c++ - 对论文有什么想法吗?

python - 2048 场比赛 - AI 平均得分不能超过 256