=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving picking and placing items. It begins by setting up the environment and resetting the task to its initial state. It initializes video recording capabilities and retrieves the positions of various objects in the environment. 

The task consists of a series of steps where the program picks three items from a table and places each one on a plate in sequence. After each pick and place action, it checks if the task is completed and prints appropriate messages. If the task ends after any step, it exits early. Finally, the environment is shut down properly after the task is completed or if an error occurs. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK is a formal representation of a problem in PDDL (Planning Domain Definition Language) for a robot to follow specific instructions.
   - CODE_FUNC describes a procedural implementation of a simulation task that executes the actions defined in the TASK.

2. **Format**: 
   - TASK is structured in a declarative format (PDDL) that defines actions, preconditions, and effects.
   - CODE_FUNC is written in a procedural programming style, detailing the sequence of operations to be performed.

3. **Execution**: 
   - TASK does not execute actions; it merely defines them and the conditions under which they can occur.
   - CODE_FUNC actively runs a simulation, executing the defined actions in a specific order.

4. **Environment Setup**: 
   - TASK includes a domain and problem definition, specifying the types of objects and their initial states.
   - CODE_FUNC initializes the environment and resets the task to its initial state programmatically.

5. **Action Handling**: 
   - TASK defines actions (pick, place, close_gripper, press) with specific preconditions and effects.
   - CODE_FUNC describes a sequence of actions (picking and placing items) without detailing the underlying preconditions and effects.

6. **Error Handling**: 
   - TASK does not include any error handling mechanisms; it assumes the actions will be executed under the defined conditions.
   - CODE_FUNC includes checks for task completion and error handling to exit early if necessary.

7. **Output**: 
   - TASK does not produce output; it is a static definition.
   - CODE_FUNC includes print statements to provide feedback on the task's progress and completion.

8. **Focus**: 
   - TASK focuses on the logical structure of the problem and the relationships between actions and states.
   - CODE_FUNC focuses on the procedural steps to achieve the task, including video recording and environment shutdown.

9. **Level of Abstraction**: 
   - TASK operates at a higher level of abstraction, defining what needs to be done without specifying how.
   - CODE_FUNC operates at a lower level, detailing the specific steps and logic required to perform the task.

10. **Language**: 
    - TASK is written in PDDL, a language specifically designed for planning problems.
    - CODE_FUNC is written in a general-purpose programming language (not specified, but likely Python or similar).

In summary, the semantic differences between TASK and CODE_FUNC are significant, as they serve different purposes and are structured in different ways.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment
from skill_code import pick, place
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        item3_pos = positions['item3']
        plate_pos = positions['plate']

        # === Execute the Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 on the plate
        print("[Task] Placing item1 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item1!")
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 on the plate
        print("[Task] Placing item2 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item2!")
            return

        # Step 5: Pick item3 from the table
        print("[Task] Picking item3 from the table.")
        obs, reward, done = pick(env, task, item3_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item3!")
            return

        # Step 6: Place item3 on the plate
        print("[Task] Placing item3 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")
-------------------

=== Instruction 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving object manipulation. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of specific objects needed for the task.

The task consists of a series of steps where the program picks up two items from a table and places them onto a plate. After each action, it checks if the task is completed and prints appropriate messages. If the task ends after picking or placing an item, it exits early. Finally, the environment is shut down properly after the task execution. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK defines a PDDL domain and problem for a robot disposal task, focusing on the actions and conditions for manipulating objects.
   - CODE_FUNC describes a function that simulates the execution of a task involving object manipulation, detailing the procedural steps taken during the simulation.

2. **Structure**: 
   - TASK is structured in a formal PDDL format, defining types, predicates, and actions with preconditions and effects.
   - CODE_FUNC is written in a programming language (likely Python), outlining a function with procedural code and control flow.

3. **Execution**: 
   - TASK does not execute any actions; it merely defines the rules and conditions under which actions can occur.
   - CODE_FUNC actively runs a simulation, executing the defined actions in a sequence and managing the state of the environment.

4. **Focus on Environment**: 
   - TASK emphasizes the logical representation of the environment and the relationships between objects and actions.
   - CODE_FUNC focuses on the practical implementation of the task, including environment setup, state management, and output messages.

5. **Output**: 
   - TASK does not produce any output; it is a declarative specification.
   - CODE_FUNC includes print statements to provide feedback on the task's progress and completion.

6. **Error Handling**: 
   - TASK does not include any error handling or conditions for failure; it assumes the actions can be executed as defined.
   - CODE_FUNC may include checks for task completion and early exits, indicating a more dynamic handling of the task execution process.

7. **Initialization**: 
   - TASK initializes the state of the world through the `:init` section in the PDDL problem definition.
   - CODE_FUNC initializes the environment and may include additional setup steps, such as video recording.

8. **Action Definition**: 
   - TASK defines actions with specific preconditions and effects in a formal manner.
   - CODE_FUNC describes actions in a more informal, procedural way, focusing on the sequence of operations rather than formal definitions.

9. **Domain Specificity**: 
   - TASK is specific to a robot disposal domain with defined types and predicates relevant to that context.
   - CODE_FUNC is more general in nature, describing a simulation function that could potentially be adapted for various tasks beyond just the robot disposal scenario.

10. **Language**: 
    - TASK is written in PDDL, a language specifically designed for planning problems.
    - CODE_FUNC is written in a programming language (likely Python), which is used for implementing algorithms and simulations.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment
from skill_code import pick, place
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        plate_pos = positions['plate']

        # === Execute Task Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 onto the plate
        print("[Task] Placing item1 onto the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item1!")
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 onto the plate
        print("[Task] Placing item2 onto the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving picking and placing items. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of three items and a plate. 

The task consists of a series of steps where the program picks each item from a table and places it on the plate, checking after each action if the task has been completed. If the task ends after any step, it prints a message and exits. Finally, it ensures that the environment is properly shut down before concluding the task.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to perform (picking up tomatoes and placing them on a plate).
   - CODE_FUNC outlines a function that simulates the execution of the task, including setup, execution, and cleanup.

2. **Detail Level**:
   - TASK provides a high-level description of the action to be performed.
   - CODE_FUNC includes implementation details, such as environment setup, state management, and task completion checks.

3. **Context**:
   - TASK is presented in the context of a planning domain (PDDL) with defined actions and predicates.
   - CODE_FUNC is described in the context of a programming function that runs a simulation.

4. **Execution Flow**:
   - TASK does not specify the order of actions or how the task is executed.
   - CODE_FUNC describes a sequential process of picking and placing items, including checks for task completion.

5. **Environment Interaction**:
   - TASK focuses on the actions of picking and placing without detailing the environment's state management.
   - CODE_FUNC explicitly mentions resetting the environment and ensuring proper shutdown after task completion.

6. **Output**:
   - TASK does not mention any output or feedback mechanism.
   - CODE_FUNC includes a mechanism to print messages upon task completion.

7. **Initialization**:
   - TASK does not include any initialization steps.
   - CODE_FUNC mentions initializing the environment and optionally starting video recording.

8. **Error Handling**:
   - TASK does not address error handling or conditions that might prevent task completion.
   - CODE_FUNC implies a check for task completion after each action, suggesting a form of error handling.

9. **State Management**:
   - TASK does not detail how the state of the robot or objects is managed.
   - CODE_FUNC indicates that it retrieves positions and manages the state of items and the environment.

10. **Focus on Specific Objects**:
    - TASK specifies "all tomatoes" as the target objects.
    - CODE_FUNC refers to "three items" generically without specifying their nature.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as TASK is a high-level instruction while CODE_FUNC is a detailed implementation of that instruction in a programming context.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment
from skill_code import pick, place
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        descriptions, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        item3_pos = positions['item3']
        plate_pos = positions['plate']

        # === Execute the Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 on the plate
        print("[Task] Placing item1 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item1!")
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 on the plate
        print("[Task] Placing item2 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item2!")
            return

        # Step 5: Pick item3 from the table
        print("[Task] Picking item3 from the table.")
        obs, reward, done = pick(env, task, item3_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item3!")
            return

        # Step 6: Place item3 on the plate
        print("[Task] Placing item3 on the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

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

=== Instruction 4 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task in a robotic environment. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of various objects needed for the task.

The task consists of a series of steps: first, it closes a gripper, then presses a switch, picks up an item, and places it on a plate. It continues by picking another item and placing it on the same plate. After each action, it checks if the task is completed and prints appropriate messages. Finally, it ensures that the environment is properly shut down after the task execution. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to perform (transfer tomatoes), while CODE_FUNC outlines a function that simulates a series of actions in a robotic environment.

2. **Content Type**: 
   - TASK is a high-level instruction in natural language, whereas CODE_FUNC is a description of a programming function and its operations.

3. **Detail Level**: 
   - TASK provides a single, clear directive, while CODE_FUNC details multiple steps and actions involved in executing a task.

4. **Context**: 
   - TASK is presented in the context of a PDDL domain and problem definition, focusing on the robot's actions and conditions. CODE_FUNC is presented in the context of a programming function that simulates the task.

5. **Execution**: 
   - TASK does not specify how the actions are executed, while CODE_FUNC describes the procedural steps taken to complete the task in a simulation.

6. **State Management**: 
   - TASK does not mention state management or checks, while CODE_FUNC includes checks for task completion and environment shutdown.

7. **Action Sequence**: 
   - TASK implies a sequence of actions (transfer tomatoes), while CODE_FUNC explicitly lists the actions taken (close gripper, press switch, pick, place).

8. **Environment Interaction**: 
   - TASK focuses on the interaction with specific objects (tomatoes and plate), while CODE_FUNC describes broader interactions with the environment and multiple objects.

9. **Output**: 
   - TASK does not specify any output or feedback mechanism, while CODE_FUNC mentions printing messages after actions.

10. **Initialization**: 
    - TASK does not include any initialization steps, while CODE_FUNC describes setting up the environment and resetting the task state.

11. **Recording**: 
    - TASK does not mention video recording, whereas CODE_FUNC includes an optional step for initializing video recording.

12. **Direct Execution**: 
    - TASK is a standalone instruction, while CODE_FUNC is part of a script that runs when executed directly.

In summary, the semantic differences between TASK and CODE_FUNC are significant, as they serve different purposes and contexts within the domain of robotic task execution.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment
from skill_code import close_gripper, press, pick, place
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions
        item1_pos = positions['item1']
        item3_pos = positions['item3']
        plate_pos = positions['plate']
        switch_pos = positions['switch']

        # === Execute the Plan ===
        # Step 1: Close the gripper
        print("[Task] Closing gripper...")
        obs, reward, done = close_gripper(env, task)
        if done:
            print("[Task] Task ended after closing gripper!")
            return

        # Step 2: Press the switch
        print("[Task] Pressing the switch...")
        obs, reward, done = press(env, task, switch_pos)
        if done:
            print("[Task] Task ended after pressing the switch!")
            return

        # Step 3: Pick item1
        print("[Task] Picking item1...")
        obs, reward, done = pick(env, task, item1_pos)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 4: Place item1 on the plate
        print("[Task] Placing item1 on the plate...")
        obs, reward, done = place(env, task, plate_pos)
        if done:
            print("[Task] Task ended after placing item1 on the plate!")
            return

        # Step 5: Pick item3
        print("[Task] Picking item3...")
        obs, reward, done = pick(env, task, item3_pos)
        if done:
            print("[Task] Task ended after picking item3!")
            return

        # Step 6: Place item3 on the plate
        print("[Task] Placing item3 on the plate...")
        obs, reward, done = place(env, task, plate_pos)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")

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

=== Instruction 5 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving picking and placing objects. It begins by setting up the environment and resetting the task to its initial state. It optionally initializes video recording for the simulation. The function retrieves the positions of two items and a plate. 

The task consists of four main steps: picking the first item from the table, placing it on the plate, picking the second item from the table, and placing it on the plate. After each action, it checks if the task is completed and prints appropriate messages. Finally, it ensures that the environment is shut down properly after the task execution. The function is executed when the script is run as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a specific action sequence for a robot to perform (tossing tomatoes), while CODE_FUNC describes a function that simulates a broader task involving picking and placing objects.
2. **Detail Level**: TASK provides a detailed PDDL representation of actions, preconditions, and effects, whereas CODE_FUNC gives a high-level overview of the simulation process without specific implementation details.
3. **Action Specification**: TASK includes specific actions (pick, place) with conditions and effects, while CODE_FUNC outlines a sequence of actions but does not specify the underlying mechanics or conditions for each action.
4. **Environment Setup**: TASK includes a detailed domain and problem definition, including object types and initial conditions, while CODE_FUNC mentions setting up the environment but lacks the formal structure of PDDL.
5. **Execution Context**: TASK is defined in a planning context (PDDL), while CODE_FUNC is described in the context of a programming function that runs a simulation.
6. **Output Handling**: TASK does not specify any output or feedback mechanism, while CODE_FUNC mentions printing messages after actions to indicate task completion.
7. **Simulation vs. Planning**: TASK is focused on planning actions based on conditions, while CODE_FUNC is focused on executing a simulation of those actions in a programmatic context.

Refined Code Generated:
-------------------
import numpy as np
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor

from env import setup_environment, shutdown_environment
from skill_code import pick, place
from video import init_video_writers, recording_step, recording_get_observation
from object_positions import get_object_positions

def run_skeleton_task():
    '''Generic skeleton for running any task in your simulation.'''
    print("===== Starting Skeleton Task =====")
    
    # === Environment Setup ===
    env, task = setup_environment()
    try:
        # Reset the task to its initial state
        _, obs = task.reset()

        # (Optional) Initialize video writers for capturing your simulation
        init_video_writers(obs)

        # Wrap the task steps for recording (if needed)
        original_step = task.step
        task.step = recording_step(original_step)
        original_get_obs = task.get_observation
        task.get_observation = recording_get_observation(original_get_obs)

        # === Retrieve Object Positions ===
        positions = get_object_positions()

        # Define object positions
        item1_pos = positions['item1']
        item2_pos = positions['item2']
        plate_pos = positions['plate']

        # === Execute the Plan ===
        # Step 1: Pick item1 from the table
        print("[Task] Picking item1 from the table.")
        obs, reward, done = pick(env, task, item1_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item1!")
            return

        # Step 2: Place item1 onto the plate
        print("[Task] Placing item1 onto the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after placing item1!")
            return

        # Step 3: Pick item2 from the table
        print("[Task] Picking item2 from the table.")
        obs, reward, done = pick(env, task, item2_pos, approach_distance=0.15)
        if done:
            print("[Task] Task ended after picking item2!")
            return

        # Step 4: Place item2 onto the plate
        print("[Task] Placing item2 onto the plate.")
        obs, reward, done = place(env, task, plate_pos, approach_distance=0.15)
        if done:
            print("[Task] Task completed successfully! Reward:", reward)
        else:
            print("[Task] Task not completed yet (done=False).")

    finally:
        # Always ensure the environment is properly shutdown
        shutdown_environment(env)

    print("===== End of Skeleton Task =====")
-------------------

