From c812d677dafc0728e49ab95cb52a35c0a1876c0c Mon Sep 17 00:00:00 2001 From: Christopher Zhang Cui Date: Mon, 5 Jan 2026 00:22:28 +0000 Subject: [PATCH] Added stricter state checking for inform7 backend --- textworld/envs/wrappers/tw_inform7.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/textworld/envs/wrappers/tw_inform7.py b/textworld/envs/wrappers/tw_inform7.py index 9f473ccf..ef1a5466 100644 --- a/textworld/envs/wrappers/tw_inform7.py +++ b/textworld/envs/wrappers/tw_inform7.py @@ -135,7 +135,10 @@ def _gather_infos(self): for info in ["score", "moves"]: if self.state[info] is not None and type(self.state[info]) is not int: - self.state[info] = int(self.state[info].strip()) + try: + self.state[info] = int(self.state[info].strip()) + except: + self.state[info] = int(self.state[info].strip().split("\n")[0]) self.state["won"] = '*** The End ***' in self.state["feedback"] self.state["lost"] = '*** You lost! ***' in self.state["feedback"]