
def generate_goals(obs):
    split_obs = obs.split("\n")
    list_object = []
    list_wall = []
    
    closed_door = []
    open_door = []
    lock_door = []
    
    for feature in split_obs:
        if "wall" in feature:
            list_wall = feature.split(": ")[1].strip().split(" ")
            list_wall = [x.replace("(","").replace(")","").split(",") for x in list_wall]
            list_wall = [  (int(x[0]), int(x[1])) for x in list_wall]
        elif "box" in feature or "key" in feature or "ball" in feature or "chest" in feature:
            object = feature.split("A")[1].split("is on tile ")[0].strip()
            object = object.replace("close","").strip()
            object = object.replace("open","").strip()
            list_object.append(object)
        elif "door" in feature:
            door = feature.split("A")[1].split("is on tile ")[0].strip()
            # object = object.replace("closed","").strip()
            # object = object.replace("open","").strip()
            # object = object.replace("locked","").strip()
            if "close" in feature:
                closed_door.append(door.replace("closed","").strip())
            elif "open" in feature:
                open_door.append(door)
            elif "lock" in feature:
                lock_door.append(door)

    list_object = list(set(list_object))
    closed_door = list(set(closed_door))
    open_door = list(set(open_door))
    lock_door = list(set(lock_door))


    free_tiles = []
    for x in range(1,21):
        for y in range(1,21):
            if (x,y) not in list_wall:
                free_tiles.append((x,y))
    
    goals = []
    
    # for coord in free_tiles:
    #     goals.append(f"go to the tile ({coord[0]},{coord[1]})")
    
    # for object in list_object:
    #     goals.append(f"pick up a {object}")
    #     goals.append(f"go to a {object}")
    #     for location in list_object:
    #         if location != object:
    #             goals.append(f"""put a {object} next to a {location}""")
    #             goals.append(f"""put a {object} next to a {location.replace("blue ","").replace("red ","").replace("green ","").replace("purple ","").replace("yellow ","").replace("grey ","").strip()}""")
    #             goals.append(f"""put a {object.replace("blue ","").replace("red ","").replace("green ","").replace("purple ","").replace("yellow ","").replace("grey ","").strip()} next to a {location}""")

    
    # for door in closed_door:
    #     goals.append(f"go to the {door}")
    #     goals.append(f"open the {door}")
        
    # for door in open_door:
    #     goals.append(f"go to the {door}")

    # for door in lock_door:
    #     goals.append(f"go to the {door}")
    #     goals.append(f"unlock the {door}")    
        
        
    # if len(lock_door) > 0:
    #     goals.append("go to a key")
    #     goals.append("unlock a door")
    
    if len(closed_door) > 0:
        goals.append("open a door")
        
    if "box" in obs:
        goals.append("go to a box")
        goals.append("pick up a box")
    
    if "ball" in obs:
        goals.append("go to a ball")
        goals.append("pick up a ball")
    
    if "key" in obs:
        goals.append("go to a key")
        goals.append("pick up a key")
        
        
    return list(set(goals))