From 673da9d4b1741d5d5257d1f71dff9e44725f20ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Alexandre=20C=C3=B4t=C3=A9?= Date: Tue, 1 Oct 2024 11:22:51 -0400 Subject: [PATCH] Do not overwrite existing information with None --- textworld/envs/wrappers/tw_inform7.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/textworld/envs/wrappers/tw_inform7.py b/textworld/envs/wrappers/tw_inform7.py index 0ad8e4c0..9f473ccf 100644 --- a/textworld/envs/wrappers/tw_inform7.py +++ b/textworld/envs/wrappers/tw_inform7.py @@ -156,7 +156,8 @@ def _send(self, command: str) -> str: def _track_info(self, info): extra_infos, _ = _detect_extra_infos(self._send('tw-extra-infos {}'.format(info))) self._tracked_infos.append(info) - self.state.update(extra_infos) + # Update the state with the new information. Avoid overwriting existing information if new value is None. + self.state.update({k: v for k, v in extra_infos.items() if k not in self.state or v is not None}) def reset(self): self._tracked_infos = []