Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix winning conditions #274

Merged
merged 9 commits into from Sep 3, 2021

Conversation

MathieuTuli
Copy link
Contributor

@MathieuTuli MathieuTuli commented Aug 31, 2021

The win_condition property as part of the generator.game.Game class (found in textworld/generator/game.py) was calling the wrong member variable for the quests. This PR fixes this by calling [Quest].win_events, not [Quest].winning_conditions as it previously was.

Further, mirrored the win_condition property to create the analogous fail_condition property, if that info is ever needed by the user.

Lastly, renamed win_condition -> win_conditions and fail_condition -> fail_conditions to more accurately represent their return values, which are a list of conditions (which are in fact, generator.game.Events)

Note (Sanity Check): winning_conditions isn't a member variable that exists, and only appears in this one file in the whole code base.

⏵ grep -r winning_conditions --include=\*.py
textworld/generator/game.py:        return [q.winning_conditions for q in self.quests]

- mirrored implementation from win condition (`generator/game.py:563`)
- Fix description to fail_conditions functions and rename
  win_condition(...) -> win_conditions(...),
  fail_condition(...) -> fail_conditions(...) for more
  accurate sense of return values
@MarcCote
Copy link
Contributor

MarcCote commented Sep 1, 2021

Thanks for the PR. Can I ask what is your use case for those functions? Since there are not used anywhere else in the code, I'm very tempted to simply delete them, actually.

If you do have a use case, proper tests should be added.

@@ -560,9 +560,14 @@ def verbs(self) -> List[str]:
return sorted(set(cmd.split()[0] for cmd in self.command_templates))

@property
def win_condition(self) -> List[Collection[Proposition]]:
def win_conditions(self) -> List[Collection[Proposition]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typing needs to be changed too. I.e., List[Tuple[Event]].

return [q.win_events for q in self.quests]

@property
def fail_conditions(self) -> List[Collection[Proposition]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typing needs to be changed too. I.e., List[Tuple[Event]].

@MathieuTuli
Copy link
Contributor Author

Thanks for the PR. Can I ask what is your use case for those functions? Since there are not used anywhere else in the code, I'm very tempted to simply delete them, actually.

If you do have a use case, proper tests should be added.

My use case lies in some work I'm doing relating to goal-conditioned RL. Having ground truth propositional logic of goal states is a required feature. As far as I could investigate, this was is the only way to retrieve that information (please correct me if I'm wrong). Although the propositional logic return by these functions uses the game's object IDs to instead of their names, so a second ID-> name lookup is actually needed, but that's just an aside. With this second lookup, I can compare against the game's EnvInfo.facts set of propositions.

Regarding tests, were there any specific guidelines that needed to be followed? My use case is just as information retrieval.

@MarcCote
Copy link
Contributor

MarcCote commented Sep 1, 2021

@MathieuTuli here's what I suggest: MathieuTuli#1

Add win_facts and fail_facts to EnvInfos.
@MathieuTuli
Copy link
Contributor Author

@MathieuTuli here's what I suggest: MathieuTuli#1

Agreed, I had this in mind but opted for the quick workaround, which in hindsight was the wrong decision. Merged your PR, changes should be reflected.

@MarcCote
Copy link
Contributor

MarcCote commented Sep 1, 2021

Alright. Waiting for all the tests to pass, then I will make a minor release.

Thank you for suggesting this new feature.

@MarcCote
Copy link
Contributor

MarcCote commented Sep 1, 2021

I just noticed the PEP8 check has failed. Here's the fix: MathieuTuli#2

@MathieuTuli
Copy link
Contributor Author

MathieuTuli commented Sep 1, 2021

I just noticed the PEP8 check has failed. Here's the fix: MathieuTuli#2

I had noticed it too, made the change directly just before you mentioned this. PEP8 should be happy now

@MarcCote
Copy link
Contributor

MarcCote commented Sep 1, 2021

Just a quick update. It seems there's an issue fetching packages from inform7.com website for running the tests on Azure pipelines. I'll check tomorrow to see if that's still an issue.

@MarcCote MarcCote merged commit f99fb87 into microsoft:master Sep 3, 2021
@MathieuTuli MathieuTuli deleted the hotfix-winning-conditions branch September 3, 2021 01:47
@MarcCote
Copy link
Contributor

MarcCote commented Sep 3, 2021

@MathieuTuli FYI TextWorld 1.4.4 is now released on PyPi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants