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 all commits
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
15 changes: 12 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,23 @@ 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 only one team guessed correctly this round
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)

return state


Expand Down