68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
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/37608790-6147-45d0-9f20-1137bb35703d.json", "r") as f:
|
|
example = json.load(f)
|
|
|
|
env = DesktopEnv(
|
|
# path_to_vm=r"""C:\Users\tianbaox\Downloads\Windows 10 x64\Windows 10 x64.vmx""",
|
|
path_to_vm=r"""C:\Users\tianbaox\Documents\Virtual Machines\Ubuntu\Ubuntu.vmx""",
|
|
# path_to_vm="/home/yuri/vmware/Ubuntu 64-bit/Ubuntu 64-bit.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()
|