=== Instruction 1 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that simulates a task in a virtual 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, including rubbish, a bin, and a switch. 

The task consists of four main steps: first, it closes a gripper; second, it presses a switch to turn on a light; third, it picks up rubbish; and finally, it places the rubbish in a bin. After each step, it checks if the task is completed and prints appropriate messages. Regardless of the outcome, the environment is shut down at the end of the function. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK defines a domain and problem for a robot to perform a specific action (putting rubbish in a bin) using PDDL (Planning Domain Definition Language).
   - CODE_FUNC describes a function that simulates the task in a virtual environment, detailing the steps taken to complete the task.

2. **Structure**: 
   - TASK is structured in a formal PDDL format, defining actions, predicates, and the initial state of the environment.
   - CODE_FUNC is written in a programming language (likely Python), outlining a procedural function with steps and logic.

3. **Execution**: 
   - TASK does not execute any actions; it merely defines the conditions and effects of actions within a planning framework.
   - CODE_FUNC executes a sequence of actions in a simulated environment, including closing a gripper, pressing a switch, picking up rubbish, and placing it in a bin.

4. **Environment Setup**: 
   - TASK specifies the initial state of the environment using predicates in PDDL.
   - CODE_FUNC includes steps to set up and reset the environment programmatically, including optional video recording.

5. **Feedback Mechanism**: 
   - TASK does not provide feedback or messages about the execution of actions.
   - CODE_FUNC includes print statements to provide feedback on the completion of each step in the task.

6. **Completion Check**: 
   - TASK does not include any mechanism to check if the task is completed.
   - CODE_FUNC checks if the task is completed after each step.

7. **Finalization**: 
   - TASK does not include any finalization steps.
   - CODE_FUNC ensures the environment is shut down at the end of the function.

8. **Action Details**: 
   - TASK defines actions with preconditions and effects in a declarative manner.
   - CODE_FUNC describes actions in an imperative manner, detailing the order of execution without formal preconditions and effects.

9. **Language**: 
   - TASK uses PDDL, which is specifically designed for planning problems.
   - CODE_FUNC uses a general-purpose programming language, which may not be specifically designed for planning tasks.

10. **Focus**: 
    - TASK focuses on the logical representation of the problem and the actions involved.
    - CODE_FUNC focuses on the procedural execution of the task in a simulated environment.

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
        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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        switch_pos = positions['switch']

        # 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 to turn on the light
        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 up the rubbish
        print("[Task] Picking up the rubbish...")
        obs, reward, done = pick(env, task, rubbish_pos)
        if done:
            print("[Task] Task ended after picking up the rubbish!")
            return

        # Step 4: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin...")
        obs, reward, done = place(env, task, bin_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 2 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function to run a simulation task involving a robotic agent. 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 key objects in the environment, including rubbish, a bin, and a switch. 

The task consists of four main steps: closing the gripper, pressing a switch to turn on a light, picking up rubbish, and placing the rubbish into a bin. After each step, it checks if the task is completed and prints appropriate messages. Finally, it ensures that the environment is properly shut down before concluding the task. The function is executed when the script is run directly.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: TASK defines a domain and problem for a robotic disposal task in PDDL, while CODE_FUNC describes a function that simulates the execution of that task.
2. **Format**: TASK is written in PDDL (Planning Domain Definition Language), whereas CODE_FUNC is written in a programming language (likely Python or similar).
3. **Structure**: TASK includes definitions of actions, predicates, and initial conditions, while CODE_FUNC outlines a procedural function with steps to execute the task.
4. **Execution**: TASK does not execute any actions; it merely defines them. CODE_FUNC actually runs a simulation of the defined task.
5. **Environment Setup**: TASK specifies the initial state of the environment in terms of predicates, while CODE_FUNC describes setting up the environment and resetting it to an initial state programmatically.
6. **Feedback Mechanism**: TASK does not provide feedback or messages about the task's progress, while CODE_FUNC includes print statements to indicate the completion of steps.
7. **Simulation Control**: CODE_FUNC includes optional video recording for the simulation, which is not mentioned in TASK.
8. **Task Steps**: TASK defines the actions available to the robot, while CODE_FUNC specifies the sequence of actions to be taken in the simulation.
9. **Completion Check**: CODE_FUNC includes checks to determine if the task is completed after each step, which is not present in TASK.
10. **Shutdown Procedure**: CODE_FUNC ensures proper shutdown of the environment after task completion, which is not addressed in TASK.

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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        switch_pos = positions['switch']

        # 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 to turn on the light
        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 up the rubbish
        print("[Task] Picking up the rubbish...")
        obs, reward, done = pick(env, task, rubbish_pos)
        if done:
            print("[Task] Task ended after picking up the rubbish!")
            return

        # Step 4: Place the rubbish into the bin
        print("[Task] Placing the rubbish into the bin...")
        obs, reward, done = place(env, task, bin_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 =====")
-------------------

=== Instruction 3 ===
Is Correct: False
Syntax Pass: False
Code Function: The code defines a function that runs a simulation task involving a robotic agent. It begins by setting up the environment and resetting the task to its initial state. The task includes several key steps: closing a gripper, pressing a switch to turn on a light, picking up rubbish, and placing the rubbish in a bin. After each action, the code checks if the task is completed and prints appropriate messages. Additionally, it initializes video recording for the simulation and retrieves object positions for the actions. Finally, it ensures that the environment is properly shut down 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 describes a specific instruction for a robot to perform, while CODE_FUNC outlines a function that simulates the execution of a series of actions, including the TASK.
2. **Structure**: TASK is presented in a PDDL format defining actions, predicates, and the problem setup, whereas CODE_FUNC is a narrative description of a function's behavior and flow.
3. **Detail Level**: TASK provides detailed preconditions and effects for each action, while CODE_FUNC summarizes the actions without specifying preconditions or effects.
4. **Execution Context**: TASK is a formal representation meant for planning and execution in a robotic domain, while CODE_FUNC describes a higher-level simulation that may include additional functionalities like video recording and error handling.
5. **Action Sequence**: TASK lists actions in a specific order based on logical conditions, while CODE_FUNC describes a sequence of actions but does not specify the logical conditions governing them.
6. **Environment Interaction**: TASK focuses on the robot's interaction with objects and locations, while CODE_FUNC includes broader aspects like environment setup and shutdown procedures.
7. **Error Handling**: CODE_FUNC mentions error handling and shutdown procedures, which are not present in TASK.
8. **Initialization**: CODE_FUNC includes initialization steps for the simulation environment, which are not part of the TASK description.
9. **Output**: CODE_FUNC mentions printing messages after actions, while TASK does not include any output or feedback mechanism.

Overall, the two serve different purposes and are structured differently, leading to these semantic differences.

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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']
        switch_pos = positions['switch']

        # 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 to turn on the light
        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 up the rubbish
        print("[Task] Picking up the rubbish...")
        obs, reward, done = pick(env, task, rubbish_pos)
        if done:
            print("[Task] Task ended after picking up the rubbish!")
            return

        # Step 4: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin...")
        obs, reward, done = place(env, task, bin_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 =====")
-------------------

=== Instruction 4 ===
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, including rubbish, a switch, and a bin. 

The task consists of four main steps: closing a gripper, pressing a switch to turn on a light, picking up rubbish, and placing the rubbish in a bin. 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 as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to follow (throwing away trash), while CODE_FUNC outlines a function that simulates the execution of a series of actions to achieve a task.

2. **Structure**: 
   - TASK is structured in PDDL (Planning Domain Definition Language) format, defining actions, predicates, and the problem domain. CODE_FUNC is a description of a procedural function in a programming context.

3. **Detail Level**: 
   - TASK provides a detailed specification of the robot's actions, preconditions, and effects in a formalized manner. CODE_FUNC provides a high-level overview of the function's purpose and steps without detailing the underlying logic or conditions.

4. **Execution Context**: 
   - TASK is a declarative representation meant for planning and reasoning about actions in a domain. CODE_FUNC is an imperative description that implies execution in a programming environment.

5. **Action Sequence**: 
   - TASK focuses on the action of throwing away trash specifically, while CODE_FUNC includes multiple actions (closing gripper, pressing a switch, picking up rubbish, placing rubbish) as part of a broader task.

6. **Environment Interaction**: 
   - TASK specifies the conditions under which actions can occur (e.g., dark room conditions affecting picking and placing), while CODE_FUNC describes the simulation of these actions without detailing the environmental constraints.

7. **Output**: 
   - TASK does not specify any output or feedback mechanism, while CODE_FUNC mentions printing messages after actions and checking task completion.

8. **Initialization**: 
   - TASK does not include any initialization steps, whereas CODE_FUNC mentions resetting the task to its initial state and optionally initializing video recording.

9. **Completion Check**: 
   - TASK does not include a mechanism for checking if the task is completed, while CODE_FUNC explicitly states that it checks for task completion after each action.

10. **Shutdown Procedure**: 
    - TASK does not mention any shutdown or cleanup process, while CODE_FUNC ensures that the environment is properly shut down after task execution.

Refined Code Generated:
-------------------
import numpy as np
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
        rubbish_pos = positions['rubbish']
        bin_pos = positions['bin']

        # 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 to turn on the light
        print("[Task] Pressing the switch...")
        obs, reward, done = press(env, task, positions['switch'])
        if done:
            print("[Task] Task ended after pressing the switch!")
            return

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

        # Step 4: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin...")
        obs, reward, done = place(env, task, bin_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 =====")
-------------------

=== Instruction 5 ===
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, including rubbish, a switch, and a bin. 

The task consists of four main steps: closing a gripper, pressing a switch, picking up rubbish, and placing the rubbish in a bin. After each step, 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 as the main program.
Similarity: {'ok': False, 'reason': 'LLM JSON parsing failed.'}
Differences: 1. **Purpose**: 
   - TASK describes a specific instruction for a robot to dispose of rubbish, while CODE_FUNC outlines a function that simulates the execution of a series of actions related to object manipulation.

2. **Structure**: 
   - TASK is presented in a PDDL format defining a domain and problem, whereas CODE_FUNC is described in a narrative format detailing the steps of a function.

3. **Content**: 
   - TASK includes definitions of actions, predicates, and initial conditions for a planning problem, while CODE_FUNC describes the procedural steps taken to execute a simulation task.

4. **Execution**: 
   - TASK is a declarative representation meant for planning and reasoning about actions, while CODE_FUNC is an imperative representation that describes how to perform those actions in a simulation.

5. **Focus**: 
   - TASK focuses on the logical conditions and effects of actions in a planning context, whereas CODE_FUNC emphasizes the operational sequence and checks for task completion.

6. **Environment Setup**: 
   - TASK specifies the initial state of the environment in terms of predicates, while CODE_FUNC mentions setting up the environment and resetting it to an initial state programmatically.

7. **Output**: 
   - TASK does not specify any output or feedback mechanism, while CODE_FUNC includes print statements to provide feedback on task completion.

8. **Action Sequence**: 
   - TASK defines actions in a general sense (pick, place, close_gripper, press) without detailing the order, while CODE_FUNC specifies a particular sequence of actions to be executed.

9. **Error Handling**: 
   - TASK does not address error handling or conditions under which actions cannot be performed, while CODE_FUNC implies checks for task completion and proper shutdown of the environment.

10. **Contextual Use**: 
    - TASK is designed for use in automated planning systems, while CODE_FUNC is intended for execution in a programming environment, likely for simulation or testing purposes.

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
        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
        rubbish_pos = positions['rubbish']
        switch_pos = positions['switch']
        bin_pos = positions['bin']

        # 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 switch!")
            return

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

        # Step 4: Place the rubbish in the bin
        print("[Task] Placing the rubbish in the bin...")
        obs, reward, done = place(env, task, bin_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()
-------------------

