From 2163a08a0db38e1a60bed7c3b45c9d7203c831d9 Mon Sep 17 00:00:00 2001 From: David Chang Date: Fri, 22 Dec 2023 19:03:54 +0800 Subject: [PATCH] ver Dec22ndv4 recorded action history --- desktop_env/envs/desktop_env.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop_env/envs/desktop_env.py b/desktop_env/envs/desktop_env.py index 712ade8..d1a8026 100644 --- a/desktop_env/envs/desktop_env.py +++ b/desktop_env/envs/desktop_env.py @@ -91,10 +91,12 @@ class DesktopEnv(gym.Env): self.result_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["result"]["type"])) self.expected_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["expected"]["type"])) - # episodic stuffs, like tmp dir and counters + # episodic stuffs, like tmp dir and counters, will be updated or reset + # when calling self.reset() self.tmp_dir: str = self.tmp_dir_base # just an init value, updated during reset self._traj_no: int = -1 self._step_no: int = 0 + self.action_history: List[Dict[str, any]] = [] def _start_emulator(self): while True: @@ -166,6 +168,7 @@ class DesktopEnv(gym.Env): print("Setting counters...") self._traj_no += 1 self._step_no = 0 + self.action_history.clear() print("Setup new temp dir...") self.tmp_dir = tempfile.mkdtemp( prefix="{:d}.{:}.".format(self._traj_no, self.task_id) @@ -200,6 +203,7 @@ class DesktopEnv(gym.Env): elif self.action_space == "pyautogui": # the set of all possible python commands insides `pyautogui` self.controller.execute_python_command(action) + self.action_history.append(action) # todo: maybe for the better here we need to add a logic to wait until the rendering is done time.sleep(pause)