Files
sci-gui-agent-benchmark/main.py
2023-12-03 21:09:05 +08:00

49 lines
1.2 KiB
Python

from desktop_env.envs.desktop_env import DesktopEnv
def human_agent():
"""
Runs the Gym environment with human input.
"""
env = DesktopEnv(
path_to_vm=r"""C:\Users\tianbaox\Documents\Virtual Machines\Win10\Win10.vmx""",
# path_to_vm="/home/yuri/vmware/Ubuntu 64-bit/Ubuntu 64-bit.vmx",
snapshot_path="base3",
)
# example setup
env.setup({"download": [("https://images.unsplash.com/photo-1683009427051-00a2fe827a2c", "C:/Users/Yuri/Desktop/1.jpg")]})
# reset the environment to certain snapshot
observation = env.reset()
done = False
for i in range(2):
# action = get_human_action()
# action = {
# "action_type": 0,
# "click_type": 3,
# }
action = "pyautogui.moveTo(10, 100)" if i == 0 else "pyautogui.click(button='right')"
observation, reward, done, info = env.step(action)
print("Observation:", observation)
print("Reward:", reward)
print("Info:", info)
print("================================\n")
if done:
print("The episode is done.")
break
env.close()
print("Environment closed.")
if __name__ == "__main__":
human_agent()