Fix the implementation of action 13 of computer
This commit is contained in:
@@ -25,6 +25,7 @@ class DesktopEnv(gym.Env):
|
||||
path_to_vm: str,
|
||||
host: str = "192.168.7.128:5000",
|
||||
snapshot_path: str = "base",
|
||||
action_space: str = "pyautogui",
|
||||
):
|
||||
# Initialize environment variables
|
||||
self.path_to_vm = path_to_vm
|
||||
@@ -35,7 +36,11 @@ class DesktopEnv(gym.Env):
|
||||
print("Initializing...")
|
||||
self._start_emulator()
|
||||
self.controller = PythonController(http_server=self.host)
|
||||
# todo: define the action space and the observation space as gym did
|
||||
|
||||
# mode: human or machine
|
||||
assert action_space in ["computer_13", "pyautogui"]
|
||||
self.action_space = action_space
|
||||
# todo: define the action space and the observation space as gym did, or extend theirs
|
||||
|
||||
def _start_emulator(self):
|
||||
while True:
|
||||
@@ -86,9 +91,12 @@ class DesktopEnv(gym.Env):
|
||||
return observation
|
||||
|
||||
def step(self, action, pause=0.5):
|
||||
# todo: support both the action space of our-designed space and the executable code space in pyautogui
|
||||
# Our action space is the set of all possible python commands insides `pyautogui`
|
||||
self.controller.execute_python_command(action)
|
||||
if self.action_space == "computer_13":
|
||||
# the set of all possible actions defined in the action representation
|
||||
self.controller.execute_action(action)
|
||||
elif self.action_space == "pyautogui":
|
||||
# the set of all possible python commands insides `pyautogui`
|
||||
self.controller.execute_python_command(action)
|
||||
|
||||
# todo: maybe for the better here we need to add a logic to wait until the rendering is done
|
||||
time.sleep(pause)
|
||||
|
||||
Reference in New Issue
Block a user