Explorar el Código

correct format string

Rodrigo Perez-Vicente hace 2 años
padre
commit
651da3455c

+ 1 - 3
gym_minigrid/envs/fetch.py

@@ -27,9 +27,7 @@ class FetchEnv(MiniGridEnv):
         ]
         self.size = size
         mission_space = MissionSpace(
-            mission_func=lambda syntax, color, type: "{} {} {}".format(
-                syntax, color, type
-            ),
+            mission_func=lambda syntax, color, type: f"{syntax} {color} {type}",
             ordered_placeholders=[MISSION_SYNTAX, COLOR_NAMES, self.obj_types],
         )
         super().__init__(

+ 2 - 6
gym_minigrid/envs/lockedroom.py

@@ -33,11 +33,7 @@ class LockedRoomEnv(MiniGridEnv):
     def __init__(self, size=19, **kwargs):
         self.size = size
         mission_space = MissionSpace(
-            mission_func=lambda lockedroom_color, keyroom_color, door_color: "get the {} key from the {} room, unlock the {} door and go to the goal".format(
-                lockedroom_color,
-                keyroom_color,
-                lockedroom_color,
-            ),
+            mission_func=lambda lockedroom_color, keyroom_color, door_color: f"get the {lockedroom_color} key from the {keyroom_color} room, unlock the {door_color} door and go to the goal",
             ordered_placeholders=[COLOR_NAMES] * 3,
         )
         super().__init__(
@@ -45,7 +41,7 @@ class LockedRoomEnv(MiniGridEnv):
             width=size,
             height=size,
             max_steps=10 * size,
-            **kwargs
+            **kwargs,
         )
 
     def _gen_grid(self, width, height):

+ 1 - 6
gym_minigrid/envs/putnear.py

@@ -20,12 +20,7 @@ class PutNearEnv(MiniGridEnv):
         self.numObjs = numObjs
         self.obj_types = ["key", "ball", "box"]
         mission_space = MissionSpace(
-            mission_func=lambda move_color, move_type, target_color, target_type: "put the {} {} near the {} {}".format(
-                move_color,
-                move_type,
-                target_color,
-                target_type,
-            ),
+            mission_func=lambda move_color, move_type, target_color, target_type: f"put the {move_color} {move_type} near the {target_color} {target_type}",
             ordered_placeholders=[
                 COLOR_NAMES,
                 self.obj_types,

+ 2 - 2
gym_minigrid/minigrid.py

@@ -166,10 +166,10 @@ class MissionSpace(spaces.Space[str]):
                         check_placeholder_list.append(placeholder)
             # Remove duplicates from the list
             check_placeholder_list = list(set(check_placeholder_list))
+
             start_id_placeholder = []
             end_id_placeholder = []
-
-            # Get the starting and ending id of the founded placeholders with possible duplicates
+            # Get the starting and ending id of the identified placeholders with possible duplicates
             new_check_placeholder_list = []
             for placeholder in check_placeholder_list:
                 new_start_id_placeholder = [