import json from desktop_env.envs.desktop_env import DesktopEnv def human_agent(): """ Runs the Gym environment with human input. """ with open("evaluation_examples/examples/f9584479-3d0d-4c79-affa-9ad7afdd8850.json", "r") as f: example = json.load(f) env = DesktopEnv( path_to_vm=r"C:\Users\tianbaox\Documents\Virtual Machines\Ubuntu\Ubuntu.vmx" , action_space="computer_13" , snapshot_path="base_setup" , instruction=example["instruction"] , config=example["config"] , evaluator=example["evaluator"] ) # reset the environment to certain snapshot observation = env.reset() done = False trajectory = [ { "action_type": "MOVE_TO", "parameters": { "x": 754, "y": 1057 } }, {"action_type": "CLICK", "parameters": {"button": "right", "num_clicks": 1}} ] for i in range(len(trajectory)): # action = get_human_action() # action = { # "action_type": 0, # "click_type": 3, # } print(trajectory[i]) observation, reward, done, info = env.step(trajectory[i], pause=5) print("Observation:", observation) print("Reward:", reward) print("Info:", info) print("================================\n") if done: print("The episode is done.") break result = env.evaluate() print("Result:", result) env.close() print("Environment closed.") if __name__ == "__main__": human_agent()