Skip to content

Commit

Permalink
Sort the commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcCote committed Sep 27, 2024
1 parent f22f086 commit b6af81a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions textworld/generator/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b6af81a

Please sign in to comment.