微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PDDL 时间建模帮助:如何在后台更改数值?

如何解决PDDL 时间建模帮助:如何在后台更改数值?

我正在尝试使用 OPTIC 建模和 RTS 游戏 (AOE2) 以获得最佳构建顺序和计划。我的想法是将村民(工人)表示为一个函数,然后资源根据村民的数量增加。此操作有效,但我认为效率低下且计划不是最佳的:

(:durative-action collect_resource
    :parameters (?r - resource) ;wood,food etc.
    :duration (= ?duration 10)
    :condition (and
      (at start (> (workers ?r) 0))
      (at start (idle ?r))
      )
    :effect (and
      (at start (not (idle ?r)))
      (at start (working ?r))
      (at end (idle ?r))
      (at end (not (working ?r)))
    (at end (increase (amount ?r) (* (collect_rate ?r)(workers ?r))))
    )
  )

我试过这个 PDDL Durative-Action: Flexible duration,但 OPTIC 不支持非线性数字条件:

(increase (amount ?r) (* (#t)(* (collect_rate ?r)(workers ?r)))

有人对更好的方法有什么建议吗?

编辑(错误消息):

Unfortunately,the planner does not supported non-linear numeric conditions,effects,or duration constraints,but one or more of these is present in
the problem you have provided.  Specifically,the sub-expression:

        (3*(workers lumber1)) * (#t)

... was encountered.  To use this planner with your problem,you will have
to reformulate it to avoid these.

域:

(define (domain aoe2)
  (:requirements :strips :typing :fluents :durative-actions :timed-initial-literals)

  (:types
    location society - object
    resource building - location
    town_center barracks - building
    lumber berries sheep gold - resource
  )

  (:predicates
    (working ?l - location)
    (idle ?l - location)
  )

  (:functions
    (idle_villagers ?s - society)
    (train_villager_time ?s - society)

    (workers ?r - resource)
    (walk_time ?r - resource)
    (collect_rate ?r - resource)
    (amount ?r - resource)

  )

  (:durative-action train_villager
    :parameters (?tc - town_center ?s - society)
    :duration (= ?duration (train_villager_time ?s))
    :condition (and
      (at start (idle ?tc))
    )
    :effect (and
      (at start (not (idle ?tc)))
      (at start (working ?tc))
      (at end (idle ?tc))
      (at end (not (working ?tc)))
      (at end (increase (idle_villagers ?s) 1))
    )
  )

  (:durative-action send_idle_to_resource
    :parameters (?r - resource ?s - society)
    :duration (= ?duration (walk_time ?r))
    :condition (and
      (at start (> (idle_villagers ?s) 0))
    )
    :effect (and
      (at start (decrease (idle_villagers ?s) 1))
      (at end (increase (workers ?r) 1))
    )
  )

  (:action send_resource_to_idle
    :parameters (?r - resource ?s - society)
    :precondition (and
      (> (workers ?r) 0)
    )
    :effect (and
      (increase (idle_villagers ?s) 1)
      (decrease (workers ?r) 1)
    )
  )

  (:durative-action collect_resource
    :parameters (?r - resource)
    :duration (= ?duration 10)
    :condition (and
      (at start (> (workers ?r) 0))
      (at start (idle ?r))
      )
    :effect (and
      (at start (not (idle ?r)))
      (at start (working ?r))
      (at end (idle ?r))
      (at end (not (working ?r)))
    (at end (increase (amount ?r) (* (collect_rate ?r)(workers ?r))))
    )
  )
)

问题

(define (problem dark_age)
    (:domain aoe2)
    (:requirements :strips :typing :fluents :durative-actions :timed-initial-literals)

    (:objects
        tc1 - town_center
        mysociety - society
        lumber1 - lumber
        sheep1 - sheep
    )

    (:init
        (= (train_villager_time mysociety) 25)
        (= (idle_villagers mysociety) 0)
        (idle tc1)

        (= (workers lumber1) 0)
        (= (walk_time lumber1) 5)
        (= (collect_rate lumber1) 3)
        (= (amount lumber1) 0)
        (idle lumber1)

        (= (workers sheep1) 5)
        (= (walk_time sheep1) 0)
        (= (collect_rate sheep1) 3)
        (= (amount sheep1) 0)
        (idle sheep1)
    )

    (:goal
        (and
            ; (= (idle_villagers mysociety) 1)
            ; (> (workers lumber1) 1)
            (> (amount lumber1) 600)
            (> (amount sheep1) 600)
        )
    )
)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。