Skip to content

Commit

Permalink
Merge pull request #27 from whitemech/fix/domain-action-formatting
Browse files Browse the repository at this point in the history
fix: missing `:action` tag
  • Loading branch information
marcofavorito authored Jun 30, 2021
2 parents 7c05194 + e1a948b commit b869df8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ that gives:
(:types type_1)
(:constants a b c)
(:predicates (p1 ?x ?y ?z) (p2 ?x ?y))
(:actions
(action-1
:parameters (?x ?y ?z)
:precondition (and (p1 ?x ?y ?z) (not (p2 ?y ?z)))
:effect (p2 ?y ?z)
)
(:action action-1
:parameters (?x ?y ?z)
:precondition (and (p1 ?x ?y ?z) (not (p2 ?y ?z)))
:effect (p2 ?y ?z)
)
)
```
Expand Down
2 changes: 1 addition & 1 deletion pddl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def effect(self) -> Formula:

def __str__(self):
"""Get the string."""
operator_str = "({0}\n".format(self.name)
operator_str = "(:action {0}\n".format(self.name)
operator_str += f" :parameters ({' '.join(map(str, self.parameters))})\n"
operator_str += f" :precondition {str(self.precondition)}\n"
operator_str += f" :effect {str(self.effect)}\n"
Expand Down
5 changes: 1 addition & 4 deletions pddl/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ def domain_to_string(domain: Domain) -> str:
body += _sort_and_print_collection("(:constants ", domain.constants, ")\n")
body += _sort_and_print_collection("(:predicates ", domain.predicates, ")\n")
body += _sort_and_print_collection(
"(:actions\n",
domain.actions,
")\n",
to_string=lambda obj: indent(str(obj), indentation) + "\n",
"", domain.actions, "", to_string=lambda obj: str(obj) + "\n",
)
result = result + "\n" + indent(body, indentation) + "\n)"
result = _remove_empty_lines(result)
Expand Down

0 comments on commit b869df8

Please sign in to comment.