=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to sequentially open two drawers. First, the robot grasps the handle of the bottom drawer and pulls it open by a specified distance. Next, it grasps the handle of the middle drawer and pulls it open by the same distance. If any error occurs during these actions, it prints an error message.
Similarity: {'ok': False, 'reason': "The code description does not mention unlocking the drawers, which is required before pulling them open according to the domain's preconditions."}
Differences: 1. **Order of Opening**:  
   - TASK: Does not specify which two drawers to open or in what order.  
   - CODE_FUNC: Specifies opening the bottom drawer first, then the middle drawer, in that order.

2. **Drawer Selection**:  
   - TASK: "Two drawers" is generic; any two drawers could be opened.  
   - CODE_FUNC: Explicitly selects the bottom and middle drawers.

3. **Error Handling**:  
   - TASK: No mention of error handling.  
   - CODE_FUNC: Includes error handling—prints an error message if an error occurs during the actions.

4. **Distance Specification**:  
   - TASK: No mention of how far to open the drawers.  
   - CODE_FUNC: Opens each drawer "by a specified distance" (implies partial or full opening, but is explicit about the action parameter).

5. **Sequentiality**:  
   - TASK: Implies both drawers should be open at the end, but does not specify if actions must be sequential or could be parallel.  
   - CODE_FUNC: Explicitly performs the actions sequentially (one after the other).

6. **Handle Grasping**:  
   - TASK: Does not mention the need to grasp the handle before opening.  
   - CODE_FUNC: Explicitly states the robot grasps the handle before pulling.

7. **Number of Drawers in Environment**:  
   - TASK: Assumes two drawers to open, but does not specify which among possibly more.  
   - CODE_FUNC: Assumes at least bottom and middle drawers exist and selects those.

8. **Completion Criteria**:  
   - TASK: Only requires that two drawers are open at the end.  
   - CODE_FUNC: The process is complete after the two specified drawers are opened, regardless of the state of other drawers.

9. **Output/Feedback**:  
   - TASK: No output or feedback specified.  
   - CODE_FUNC: Prints an error message if something goes wrong.

10. **Implicit Preconditions**:  
    - TASK: Assumes drawers can be opened without specifying preconditions (e.g., unlocked, closed, handle available).  
    - CODE_FUNC: Implies the robot will attempt to grasp the handle and pull, but does not specify handling for locked drawers or missing handles (though error handling may catch this).

---

**Summary**: The main semantic differences are specificity (which drawers, order, and method), error handling, and action details (handle grasping, distance, sequentiality).

Refined Code Generated:
-------------------
"""Module to open any two drawers using the robot controller."""
from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Open any two drawers by unlocking and pulling them."""
    robot = RobotController()

    # Open drawer_bottom
    robot.execute_movement(Object["drawer_bottom_handle"], mode=2, axis=0)  # Unlock bottom drawer
    robot.execute_movement(Object["drawer_bottom_handle"], mode=1, axis=0)  # Pick handle
    robot.execute_movement(Object["drawer_bottom_handle"], mode=4, axis=0, distance=0.1)  # Pull to open

    # Open drawer_middle
    robot.execute_movement(Object["drawer_middle_handle"], mode=2, axis=0)  # Unlock middle drawer
    robot.execute_movement(Object["drawer_middle_handle"], mode=1, axis=0)  # Pick handle
    robot.execute_movement(Object["drawer_middle_handle"], mode=4, axis=0, distance=0.1)  # Pull to open

def main():
    """Main entry point to execute the drawer opening task."""
    long_horizon_task2_oracle_seq()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to sequentially open two drawers. First, the robot grasps the bottom drawer handle and pulls the bottom drawer open. Next, it grasps the middle drawer handle and pulls the middle drawer open. If any error occurs during these actions, it prints an error message.
Similarity: {'ok': True, 'reason': "The described code functionally achieves the task by sequentially pulling open two drawers using the appropriate handles, which matches the domain's requirements for opening drawers."}
Differences: 1. **Explicitness of Sequence**:  
   - **TASK**: The instruction "Pull open a pair of drawers" does not specify which drawers or the order in which to open them.
   - **CODE_FUNC**: Specifies that the robot first opens the bottom drawer, then the middle drawer, in that order.

2. **Error Handling**:  
   - **TASK**: No mention of error handling or what to do if an action fails.
   - **CODE_FUNC**: Explicitly states that if any error occurs during the actions, an error message is printed.

3. **Drawer Identification**:  
   - **TASK**: Refers generically to "a pair of drawers" without specifying which ones.
   - **CODE_FUNC**: Specifically identifies the "bottom" and "middle" drawers by their handles.

4. **Assumed Preconditions**:  
   - **TASK**: Does not mention any preconditions (e.g., drawers must be unlocked, robot must be at a certain location, etc.).
   - **CODE_FUNC**: Implies that the robot will perform the necessary actions to grasp the correct handle and pull, assuming preconditions are met, but does not detail them.

5. **Level of Detail**:  
   - **TASK**: High-level, abstract instruction.
   - **CODE_FUNC**: More concrete, specifying the exact sequence and error handling.

6. **Number of Drawers**:  
   - **TASK**: "A pair" could mean any two drawers.
   - **CODE_FUNC**: The two drawers are specifically the bottom and middle ones.

7. **Action Granularity**:  
   - **TASK**: Only specifies the end goal (drawers open).
   - **CODE_FUNC**: Specifies the steps (grasp handle, pull open) and the order.

8. **Output/Feedback**:  
   - **TASK**: No mention of output or feedback.
   - **CODE_FUNC**: Prints an error message if something goes wrong.

9. **Implicit Assumptions**:  
   - **TASK**: Leaves open which drawers, order, and error handling.
   - **CODE_FUNC**: Makes explicit choices for all of these.

10. **Domain Knowledge Usage**:  
    - **TASK**: Does not reference domain-specific objects (handles, specific drawers).
    - **CODE_FUNC**: Uses domain-specific knowledge (handle_bottom, handle_middle, etc.).

Refined Code Generated:
-------------------
"""Module to pull open a pair of drawers using the robot controller."""

from object_list import Object
from skill_mapping import RobotController

def pull_open_pair_of_drawers():
    """Pull open any two drawers."""
    robot = RobotController()
    drawers_to_open = [
        ("drawer_bottom_handle",),
        ("drawer_middle_handle",)
    ]
    for handle_name_tuple in drawers_to_open:
        handle_name = handle_name_tuple[0]
        robot.execute_movement(Object[handle_name], mode=1, axis=0)
        robot.execute_movement(Object[handle_name], mode=4, distance=0.1)

def main():
    """Main entry point to pull open a pair of drawers."""
    pull_open_pair_of_drawers()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to sequentially open three drawers (bottom, middle, and top) by interacting with their handles. For each drawer, the robot first moves to pick the handle and then pulls the drawer open by a specified distance. The process is repeated for all three drawers in order from bottom to top. If any error occurs during execution, it is caught and printed.
Similarity: {'ok': False, 'reason': 'The code does not check whether drawers are unlocked before attempting to open them, so it may try to open locked drawers, failing to achieve the task of opening all unlocked drawers.'}
Differences: 1. **Explicit Sequential Order**:  
   - CODE_FUNC specifies that drawers are opened in a fixed sequence: bottom, then middle, then top.  
   - TASK only requires that all unlocked drawers be opened, with no specified order.

2. **Assumption of Drawer State**:  
   - CODE_FUNC assumes all three drawers (bottom, middle, top) are to be opened, regardless of their locked/unlocked state.  
   - TASK requires opening only those drawers that are unlocked.

3. **Error Handling**:  
   - CODE_FUNC includes error catching and printing.  
   - TASK does not mention error handling.

4. **Handle Interaction**:  
   - CODE_FUNC explicitly describes picking up the handle and pulling the drawer open by a specified distance.  
   - TASK only specifies the end goal (drawers open), not the method.

5. **Implicit Drawer List**:  
   - CODE_FUNC operates on a hardcoded set of three drawers.  
   - TASK is general and applies to any number of unlocked drawers.

6. **No Mention of Drawer State Change**:  
   - CODE_FUNC does not check or change the locked/unlocked state of drawers.  
   - TASK is explicit that only unlocked drawers should be opened.

7. **No Mention of Drawer Contents or Other Preconditions**:  
   - CODE_FUNC does not consider whether drawers are full, empty, or partially filled, nor does it check for other preconditions.  
   - TASK is silent on these, but the domain allows for such considerations.

8. **No Mention of Robot Location**:  
   - CODE_FUNC implicitly moves the robot as needed to interact with handles.  
   - TASK does not specify robot movement.

9. **No Mention of Handle Availability**:  
   - CODE_FUNC assumes handles are available and can be picked up.  
   - TASK does not mention handles.

10. **No Mention of Closing Drawers**:  
    - CODE_FUNC only opens drawers.  
    - TASK only requires opening, so this is aligned.

**Summary**:  
The main semantic differences are that CODE_FUNC is more specific (fixed drawers, fixed order, assumes all are to be opened, includes error handling, and specifies method), while TASK is more general (all unlocked drawers, any order, no method specified).

Refined Code Generated:
-------------------
"""Module to open all unlocked drawers using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def open_all_unlocked_drawers():
    """Open all unlocked drawers by picking their handles and pulling them open."""
    robot = RobotController()

    # List of all drawers and their corresponding handles
    drawers = [
        {"drawer": "drawer_bottom", "handle": "drawer_bottom_handle"},
        {"drawer": "drawer_middle", "handle": "drawer_middle_handle"},
        {"drawer": "drawer_top", "handle": "drawer_top_handle"},
    ]

    for item in drawers:
        drawer_name = item["drawer"]
        handle_name = item["handle"]

        # Check if the drawer is unlocked before attempting to open
        if robot.is_drawer_unlocked(drawer_name):
            # Pick the handle
            robot.execute_movement(Object[handle_name], mode=1, axis=0)
            # Pull the drawer open using the handle
            robot.execute_movement(Object[handle_name], mode=4, distance=0.1)

def main():
    """Main function to execute the task of opening all unlocked drawers."""
    open_all_unlocked_drawers()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to sequentially open two drawers. First, the robot grasps the bottom drawer handle and pulls the bottom drawer open. Next, it grasps the middle drawer handle and pulls the middle drawer open. If any error occurs during these actions, it prints an error message.
Similarity: {'ok': True, 'reason': 'The described code uses the available actions to sequentially open two drawers, which matches the task requirement.'}
Differences: 1. **Specificity of Drawers**:  
   - **TASK**: The instruction is to "slide open two of the drawers" without specifying which drawers.
   - **CODE_FUNC**: The code specifically opens the bottom drawer first, then the middle drawer.

2. **Order of Operations**:  
   - **TASK**: No order is implied or required for which two drawers to open.
   - **CODE_FUNC**: The drawers are opened in a fixed sequence: bottom, then middle.

3. **Error Handling**:  
   - **TASK**: No mention of error handling or what to do if an action fails.
   - **CODE_FUNC**: If an error occurs during the process, an error message is printed.

4. **Number of Drawers**:  
   - **TASK**: The instruction is to open any two drawers (out of possibly more).
   - **CODE_FUNC**: Only the bottom and middle drawers are opened; the top drawer is not considered.

5. **Implicit Preconditions**:  
   - **TASK**: Assumes the drawers can be opened, but does not specify preconditions (e.g., unlocked, closed).
   - **CODE_FUNC**: Assumes the robot can grasp the handle and the drawer can be pulled open, but does not explicitly check for all preconditions (e.g., unlocked state).

6. **Generalization**:  
   - **TASK**: The instruction is general and could apply to any two drawers.
   - **CODE_FUNC**: The implementation is hardcoded for two specific drawers.

7. **Completion Criteria**:  
   - **TASK**: The task is complete when any two drawers are open.
   - **CODE_FUNC**: The task is complete only when the bottom and middle drawers are open.

8. **Feedback/Output**:  
   - **TASK**: No output or feedback is specified.
   - **CODE_FUNC**: Provides feedback in the form of an error message if something goes wrong.

9. **Assumed Robot State**:  
   - **TASK**: No assumption about the robot's initial state.
   - **CODE_FUNC**: Assumes the robot starts in a state where it can immediately begin the sequence (e.g., at the correct location, hand empty, etc.).

10. **Handle Selection**:  
    - **TASK**: Does not specify which handles to use.
    - **CODE_FUNC**: Explicitly selects the handles for the bottom and middle drawers.

Refined Code Generated:
-------------------
"""Module to slide open any two drawers using the robot controller."""

from Object_list import Object
from skill_mapping import RobotController

def slide_open_two_drawers():
    """Slides open any two drawers."""
    robot = RobotController()
    # List of available drawers and their handles
    drawers = [
        ("drawer_bottom_handle", "drawer_bottom"),
        ("drawer_middle_handle", "drawer_middle"),
        ("drawer_top_handle", "drawer_top"),
    ]
    opened = 0
    for handle_name, drawer_name in drawers:
        try:
            # Pick the handle
            robot.execute_movement(Object[handle_name], mode=1, axis=0)
            # Pull the drawer open
            robot.execute_movement(Object[handle_name], mode=4, distance=0.1)
            opened += 1
            if opened == 2:
                break
        except Exception as error:
            continue

def main():
    """Main entry point to slide open two drawers."""
    slide_open_two_drawers()

if __name__ == "__main__":
    main()
-------------------

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: This code controls a robot to sequentially open three drawers (bottom, middle, and top) by first picking each drawer's handle and then pulling the drawer open. For each drawer, the robot first grasps the handle and then pulls the drawer by a specified distance. The process is repeated for all three drawers, and any errors during the actions are caught and printed. The sequence is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'The code does not check whether drawers are locked or unlocked before attempting to open them, so it may try to open locked drawers, which does not satisfy the instruction to only uncover drawers that aren’t locked.'}
Differences: 1. **Scope of Drawers Opened**
   - **TASK:** Specifies to "uncover every drawer that isn’t locked," i.e., only drawers that are *not locked* should be opened.
   - **CODE_FUNC:** Opens all three drawers (bottom, middle, top) *regardless of their locked/unlocked state* as described; there is no mention of checking whether a drawer is locked before attempting to open it.

2. **Conditionality Based on Drawer State**
   - **TASK:** Implies a conditional check: only drawers that are *not locked* should be opened.
   - **CODE_FUNC:** No conditional check for the locked state; the code attempts to open all drawers in sequence.

3. **Completeness Relative to Task**
   - **TASK:** The set of drawers to be opened is determined dynamically by their locked/unlocked state.
   - **CODE_FUNC:** The set of drawers to be opened is statically determined (always bottom, middle, top), not based on their locked/unlocked state.

4. **Error Handling**
   - **TASK:** No mention of error handling; the focus is on the logical requirement.
   - **CODE_FUNC:** Explicitly mentions catching and printing errors during actions.

5. **Action Semantics**
   - **TASK:** "Uncover" is interpreted as "open" in the context of drawers.
   - **CODE_FUNC:** The code performs "open" by picking the handle and pulling the drawer, which matches the domain's action model.

6. **Order of Operations**
   - **TASK:** No specified order for opening drawers.
   - **CODE_FUNC:** Opens drawers in a fixed order: bottom, middle, top.

7. **Assumption of Drawer Handles**
   - **TASK:** Assumes the robot can open any unlocked drawer, possibly by any means.
   - **CODE_FUNC:** Assumes the robot must pick the handle before pulling the drawer.

8. **Handling of Locked Drawers**
   - **TASK:** Locked drawers are explicitly excluded from being opened.
   - **CODE_FUNC:** No mechanism to skip or avoid locked drawers; attempts to open all.

9. **Generalization**
   - **TASK:** General instruction applicable to any number of drawers and any locked/unlocked configuration.
   - **CODE_FUNC:** Hardcoded for three specific drawers.

10. **State Awareness**
    - **TASK:** Requires knowledge of the locked/unlocked state of each drawer.
    - **CODE_FUNC:** No evidence of state checking before action.

---

**Summary:**  
The main semantic difference is that the TASK requires opening only *unlocked* drawers, while the CODE_FUNC attempts to open all drawers without checking their locked state. There are also differences in generality, error handling, and order of operations.

Refined Code Generated:
-------------------
"""Module to uncover every drawer that isn’t locked by opening only unlocked drawers."""
from Object_list import Object
from skill_mapping import RobotController

def long_horizon_task2_oracle_seq():
    """Open every drawer that is not locked."""
    robot = RobotController()

    # List of drawers and their corresponding handles
    drawers = [
        {"drawer": "drawer_bottom", "handle": "drawer_bottom_handle"},
        {"drawer": "drawer_middle", "handle": "drawer_middle_handle"},
        {"drawer": "drawer_top", "handle": "drawer_top_handle"},
    ]

    for item in drawers:
        drawer_name = item["drawer"]
        handle_name = item["handle"]

        # Check if the drawer is unlocked before attempting to open
        try:
            if robot.get_drawer_state(drawer_name) == "unlocked":
                # Pick the handle
                robot.execute_movement(Object[handle_name], mode=1, axis=0)
                # Pull the drawer open
                robot.execute_movement(Object[handle_name], mode=4, distance=0.1)
        except Exception as error:
            print(f"Error while processing {drawer_name}: {error}")

def main():
    """Main entry point to execute the task."""
    long_horizon_task2_oracle_seq()

if __name__ == "__main__":
    main()
-------------------

