Browse Source

simplify if-statement

Rodrigo Perez-Vicente 2 years ago
parent
commit
85d412d872
1 changed files with 6 additions and 11 deletions
  1. 6 11
      gym_minigrid/minigrid.py

+ 6 - 11
gym_minigrid/minigrid.py

@@ -244,17 +244,12 @@ class MissionSpace(spaces.Space[str]):
             # Check that place holder lists are the same
             if self.ordered_placeholders is not None:
                 # Check length
-                if len(self.order_placeholder) == len(other.order_placeholder):
-
-                    # Placeholder list are ordered in placing order in the mission string
-                    for placeholder, other_placeholder in zip(
-                        self.order_placeholder, other.order_placeholder
-                    ):
-                        if set(placeholder) == set(other_placeholder):
-                            continue
-                        else:
-                            return False
-
+                if (len(self.order_placeholder) == len(other.order_placeholder)) and (
+                    all(
+                        set(i) == set(j)
+                        for i, j in zip(self.order_placeholder, other.order_placeholder)
+                    )
+                ):
                     # Check mission string is the same with dummy space placeholders
                     test_placeholders = [""] * len(self.order_placeholder)
                     mission = self.mission_func(*test_placeholders)