aibasel / pyperplan

A lightweight STRIPS planner written in Python.
GNU General Public License v3.0
93 stars 41 forks source link

fix string representation for objects in problem struct #19

Closed tomsilver closed 2 years ago

tomsilver commented 2 years ago

Closes #18

Example of print("Problem:", problem) before this change:

Problem: < Problem definition: logistics-4-0 Domain: logistics Objects: ['airplane', 'airport', 'airport', 'location', 'location', 'city', 'city', 'truck', 'truck', 'package', 'package', 'package', 'package', 'package', 'package'] Initial State: ["at[('apn1', airplane), ('apt2', airport)]", "at[('tru1', truck), ('pos1', location)]", "at[('obj11', package), ('pos1', location)]", "at[('obj12', package), ('pos1', location)]", "at[('obj13', package), ('pos1', location)]", "at[('tru2', truck), ('pos2', location)]", "at[('obj21', package), ('pos2', location)]", "at[('obj22', package), ('pos2', location)]", "at[('obj23', package), ('pos2', location)]", "in-city[('pos1', location), ('cit1', city)]", "in-city[('apt1', airport), ('cit1', city)]", "in-city[('pos2', location), ('cit2', city)]", "in-city[('apt2', airport), ('cit2', city)]"] Goal State : ["at[('obj11', (physobj,)), ('apt1', (place,))]", "at[('obj23', (physobj,)), ('pos1', (place,))]", "at[('obj13', (physobj,)), ('apt1', (place,))]", "at[('obj21', (physobj,)), ('pos1', (place,))]"] >

After this change:

Problem: < Problem definition: logistics-4-0 Domain: logistics Objects: ['apn1', 'apt1', 'apt2', 'cit1', 'cit2', 'obj11', 'obj12', 'obj13', 'obj21', 'obj22', 'obj23', 'pos1', 'pos2', 'tru1', 'tru2'] Initial State: ["at[('apn1', airplane), ('apt2', airport)]", "at[('tru1', truck), ('pos1', location)]", "at[('obj11', package), ('pos1', location)]", "at[('obj12', package), ('pos1', location)]", "at[('obj13', package), ('pos1', location)]", "at[('tru2', truck), ('pos2', location)]", "at[('obj21', package), ('pos2', location)]", "at[('obj22', package), ('pos2', location)]", "at[('obj23', package), ('pos2', location)]", "in-city[('pos1', location), ('cit1', city)]", "in-city[('apt1', airport), ('cit1', city)]", "in-city[('pos2', location), ('cit2', city)]", "in-city[('apt2', airport), ('cit2', city)]"] Goal State : ["at[('obj11', (physobj,)), ('apt1', (place,))]", "at[('obj23', (physobj,)), ('pos1', (place,))]", "at[('obj13', (physobj,)), ('apt1', (place,))]", "at[('obj21', (physobj,)), ('pos1', (place,))]"] >
tomsilver commented 2 years ago

It looks like the failing check is related to autoformatting with black? I installed black and ran it, and it led to a change in a file not changed in this PR:

diff --git a/pyperplan/grounding.py b/pyperplan/grounding.py
index fd7e414..b8f9456 100644
--- a/pyperplan/grounding.py
+++ b/pyperplan/grounding.py
@@ -245,7 +245,7 @@ def _find_pred_in_init(pred_name, param, sig_pos, init):
     """
     match_init = None
     if sig_pos == 0:
-        match_init = re.compile(fr"\({pred_name} {param}.*")
+        match_init = re.compile(rf"\({pred_name} {param}.*")
     else:
         reg_ex = r"\(%s\s+" % pred_name
         reg_ex += r"[\w\d-]+\s+" * sig_pos
jendrikseipp commented 2 years ago

I've seen this error in other projects. I'll fix it later on the main branch.