def pick_two_obj_then_place(self, objecttype, receptacletype):
    def pick_two_obj_then_place():
        if not hasattr(self, "old_object_name"):
            self.old_object_name = None

        def place_object(entity_name, receptacle_name):
            self.goto(receptacle_name)
            r_entity = self.seen_entitys[receptacle_name]
            if r_entity.openable and not r_entity.isopen:
                self.open_receptacle(r_entity.name)
            self.put(entity_name, receptacle_name)

        # Find the object
        entity = self.find_object(objecttype)
        if entity is None:
            # Find receptacletypes that can contain the object
            r_types = self.find_canbe_contained(objecttype)
            if r_types is None:
                # Explore the environment
                self.explore()
                return
            else:
                # Check each receptacletype to find the object
                for r_type in r_types:
                    r_entitys = self.find_receptacles(r_type)
                    if r_entitys is None:
                        continue
                    for r_entity in r_entitys:
                        self.goto(r_entity.name)
                        if r_entity.openable and not r_entity.isopen:
                            self.open_receptacle(r_entity.name)
                            return
        else:
            # Place the object in the receptacle
            if self.old_object_name != entity.name:
                place_object(entity.name, receptacletype)
                self.old_object_name = entity.name
                return

        # Find another object to place in the receptacle
        object_entitys = self.find_objects(objecttype)
        for obj_entity in object_entitys:
            if obj_entity.name != self.old_object_name:
                place_object(obj_entity.name, receptacletype)
                return

    pick_two_obj_then_place()