I'm encountering an issue with a particular section of code.
The compiler is indicating a syntax error within the first set of nested "when" conditions, on the 5th line of code. Could be possible that PDDL doesn't accept nested conditions? Is there a potential solution to address this problem?
:effect (and
(when
(and (not (light-on ?room)))
(and (light-on ?room) (when
(and (vampire-is-in ?room))
(and (when
(and (not (light-on ?anti-clockwise-neighbor)
(and (not(vampire-is-in ?room))(vampire-is-in ?anti-clockwise-neighbor)))))
(when
(and (light-on ?anti-clockwise-neighbor))
(and (not (vampire-is-in ?room)) (vampire-is-in ?clockwise-neighbor))))))
)
(when
(and (light-on ?room))
(and (not (light-on ?room)) (when
(and (slayer-is-in ?room))
(and (when
(and (light-on ?clockwise-neighbor))
(and (not (slayer-is-in ?room)) (slayer-is-in ?clockwise-neighbor)))
(when
(and (not (light-on ?clockwise-neighbor)))
(and (not(slayer-is-in ?room)) (slayer-is-in ?anti-clockwise-neighbor))))))
)
)
Looking at the grammar, nested conditional effects are not allowed:
A when expression is as follows:
So only a
c-effectcan generate awhen. But if you look at the expansion of<cond-effect>, it expands to a conjunction of<p-effect>s. I suspect that "p-effect" is supposed to be an abbreviation for primitive effect. Ap-effectis effectively a terminal and cannot be expanded to anything containing ac-effect. Ergo nested conditional effects are forbidden.Of course you can easily flatten your nested conditional effects by making the guard conditions more complex.
Note I base this answer on the PDDL 2.1 paper (with grammar) by Fox and Long. The grammar of conditional effects could have changed since then, but I bet it hasn't.