-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexploration.py
More file actions
61 lines (50 loc) · 1.68 KB
/
Copy pathexploration.py
File metadata and controls
61 lines (50 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import json
import uuid
import argparse
import time as t
from datetime import datetime
import random
from config.config import Config
from agents.agent import Agent
from envs.desktop_env import DesktopEnv
def main():
configs = Config.get_instance().config_data
path = configs["LOG_ROOT"]
related_apps = ["Cursor","ShareX","Zotero","Evernote","Windows PowerShell ISE"]
for i in range(1000):
related_app = random.choice(related_apps)
try:
print(f"trajectory {i+1} / {100} is running...")
id = str(uuid.uuid4())
if not os.path.exists(f"{configs['LOG_ROOT']}/{id}"):
os.makedirs(f"{configs['LOG_ROOT']}/{id}")
env = DesktopEnv(
path_to_vm=configs["VM_PATH"],
observation_space=["Screen_A11Y"],
action_space="pyautogui",
snapshot_name="init_state",
headless=True,
uuid=id,
related_app=related_app,
)
agent = Agent(
observation_space=["Screen_A11Y"],
action_space="pyautogui",
uuid=id,
related_app=related_app,
)
step = 0
while True:
observation = env.get_observation()
action, status = agent.get_action(observation)
env.execute_action(action)
step += 1
agent.step = step
env.step = step
if status == "FINISH" or step > configs["MAX_STEP"]:
break
except Exception as e:
print(e)
if __name__ == "__main__":
main()