Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrative planning problems parsing #654

Open
MFaisalZaki opened this issue Dec 27, 2024 · 0 comments
Open

Narrative planning problems parsing #654

MFaisalZaki opened this issue Dec 27, 2024 · 0 comments

Comments

@MFaisalZaki
Copy link

User Story

Narrative planning problems have a modified action format (e.g., :fail, ':agents') and keyword predicates such as believes and 'intends'.

Here is an example of an action:

(:action search-for
        :parameters  (?character - character ?thing - thing ?room - room)
        :precondition
            (and
                (at ?character ?room)
                (in ?thing ?room)
            )
        :effect
            (and
                (has ?character ?thing)
                (not (in ?thing ?room))

                (believes ?character (has ?character ?thing))
                (believes ?character (not (in ?thing ?room)))
                (not (believes ?character (not (has ?character ?thing))))
                (not (believes ?character (in ?thing ?room)))
            )
        :fail
            (when (and (not (in ?thing ?room)) (at ?character ?room))
                (and
                    (not (believes ?character (in ?thing ?room)))
                    (believes ?character (not (in ?thing ?room)))
                )
            )
        :agents (?character)
    )

I have modified the PDDLGrammar to parse the :fail and :agents by changing action_def in PDDLGrammar:

agents = set_results_name(
            Suppress("(")
            - ZeroOrMore(
                Group(
                    Located(Group(OneOrMore(variable)) + Optional(Suppress("-") + name))
                )
            )
            + Suppress(")"),
            "agents",
        )

action_def = Group(
            Suppress("(")
            + ":action"
            - set_results_name(name, "name")
            + ":parameters"
            - Suppress("(")
            + parameters
            + Suppress(")")
            + Optional(":precondition" - set_results_name(nested_expr(), "pre"))
            + Optional(":effect" - set_results_name(nested_expr(), "eff"))
            + Optional(":observe" - set_results_name(nested_expr(), "obs"))
            + Optional(":fail" - set_results_name(nested_expr(), "fail"))
            + Optional(":agents" - agents)
            + Suppress(")")
        )

Also modified the requirements:

require_def = (
            Suppress("(")
            + ":requirements"
            + OneOrMore(
                one_of(
                    ":strips :typing :negative-preconditions :disjunctive-preconditions :equality :existential-preconditions :universal-preconditions :quantified-preconditions :conditional-effects :fluents :numeric-fluents :adl :durative-actions :duration-inequalities :timed-initial-literals :timed-initial-effects :action-costs :hierarchy :method-preconditions :constraints :contingent :preferences :expression-variables :intentionality :belief"
                )
            )
            + Suppress(")")
        )

Now I am facing a problem when parsing the believes predicate since such predicate's args are (believes <agent> <fact>) (e.g., (not (believes ?character (not (has ?character ?thing))))).

Any advice on parsing this since I am getting the well-formed exception?

rooms-domain-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant