Skip to content

Make sure the game ends if either team guesses correctly #263

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

Merged
merged 2 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions kaggle_environments/envs/llm_20_questions/llm_20_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,17 @@ def interpreter(state, env):
step = state[0].observation.step

end_early = (active1 and active1.status) in (TIMEOUT, ERROR) or (active2 and active2.status in (TIMEOUT, ERROR))
either_guessed = False
one_guessed = False
two_guessed = False

if active1 is not None:
guessed = False
if active1.observation.role == GUESSER:
guessed = guesser_action(active1, inactive1, step)
either_guessed = guessed
one_guessed = guessed
else:
answerer_action(active1, inactive1)

if active1.status in (TIMEOUT, ERROR):
end_game(active1, inactive1, 0, active1.status, DONE)
elif end_early:
Expand All @@ -187,16 +189,24 @@ def interpreter(state, env):
guessed = False
if active2.observation.role == GUESSER:
guessed = guesser_action(active2, inactive2, step)
either_guessed = either_guessed or guessed
two_guessed = guessed
else:
answerer_action(active2, inactive2)

if active2.status in (TIMEOUT, ERROR):
end_game(active2, inactive2, 0, active2.status, DONE)
elif end_early:
end_game(active2, inactive2, 0, DONE, DONE)
else:
increment_turn(active2, inactive2, step, guessed)

# make sure to end the game if either team guessed
if one_guessed or two_guessed:
if one_guessed and not two_guessed:
end_game(active2, inactive2, 0, DONE, DONE)
elif two_guessed and not one_guessed:
end_game(active1, inactive1, 0, DONE, DONE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we also end if both guess?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will already be taken care of in the guesser_action where they will be given reward and set status to DONE

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, you don't need the wrapper if one_guessed or two_guessed clause?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I can remove that


return state


Expand Down
Loading