我正在尝试使用 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)
)
)
)