I'm trying to model and RTS game (AOE2) for an optimal build order and plan using OPTIC. My thought is to represent villagers (workers) as a function, then resources increase depending on the number of villagers. This action works, but I believe is inefficient and the plans are not optimal:
(: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))))
)
)
I tried this PDDL Durative-Action: Flexible duration, but OPTIC doesn't support non-linear numeric conditions:
(increase (amount ?r) (* (#t)(* (collect_rate ?r)(workers ?r)))
Does anyone have any suggestions for a better approach?
EDIT (error message):
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.
Domain:
(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))))
)
)
)
Problem
(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)
)
)
)