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

Fixed remove_character() leaving empty indexes #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rjstebe
Copy link

@rjstebe rjstebe commented Mar 13, 2021

When a monster kills a character, the character is removed only after update_characters(), so the characters dictionary can end up having indexes that have empty character lists, like this: {40: []}.

This can cause the condition not self.world.characters in game.done() and a similar condition in our group's terminal state checks to return False when there are no characters instead of True.

I added a couple lines to world.remove_character() to check if the removed character leaves its list empty, and if so deletes the index. Tested by printing the result of not wrld.characters in a sensed world where the monster kills the player in Variant 2 of Scenario 2, and it seems to work now.

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.

1 participant