Added stricter state checking for inform7 backend #369
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a stronger check when parsing the "score" and "moves" fields for info in the inform7 backend.
https://github.com/pearls-lab/TextWorld/blob/c812d677dafc0728e49ab95cb52a35c0a1876c0c/textworld/envs/wrappers/tw_inform7.py#L138
This is largely needed for using Textworld to train Large Language Models, as it appears that some outputs from the models can cause the inform7 backend to mistake malformed outputs as part of its underlying state tracking, thus leading to an error here.
The try catch here isn't a particularly elegant solution but is robust enough that I haven't had the need to modify it, nor encountered this error again, across a large number of RL training runs.