From b6af81a4e1bd46be9c0a3a9366f26c1bdbf631f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Alexandre=20C=C3=B4t=C3=A9?= Date: Fri, 19 Jul 2024 14:34:52 -0400 Subject: [PATCH] Sort the commands --- textworld/generator/game.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/textworld/generator/game.py b/textworld/generator/game.py index df324017..1096f137 100644 --- a/textworld/generator/game.py +++ b/textworld/generator/game.py @@ -596,16 +596,16 @@ def possible_admissible_commands(self) -> List[str]: type2names[f'{{{type}}}'].append(name) templates = [re.sub(r"{.*?}", "{{{}}}", template).format(*mappings) - for template in self.command_templates - for mappings in product(*[[arg.strip('{}')] + self.kb.types.descendants(arg.strip('{}')) - for arg in re.findall(r"{.*?}", template)])] + for template in self.command_templates + for mappings in product(*[[arg.strip('{}')] + self.kb.types.descendants(arg.strip('{}')) + for arg in re.findall(r"{.*?}", template)])] templates = sorted(set(templates)) - commands = [re.sub(r"{.*?}", "{}", template).format(*mappings) for template in templates for mappings in product(*[type2names[arg] for arg in re.findall(r"{.*?}", template)])] - return commands + + return sorted(commands) @property def objective(self) -> str: