Skip to content

fix: update kuhnpoker env #103

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Benjamin-eecs
Copy link
Collaborator

@Benjamin-eecs Benjamin-eecs commented May 18, 2025

This pull request focuses on improving the logic and robustness of the Kuhn Poker environment in textarena/envs/KuhnPoker/env.py. The changes address several issues, including incorrect game state handling, winner determination, and round transitions, while also adding safeguards to prevent errors during gameplay.

Game state and logic fixes:

  • Corrected the initialization of current_round in the reset method to start from 0 instead of 1.
  • Fixed the winner determination logic in _init_round to compare the correct chip counts for each player.
  • Added a check in _init_round to return immediately after setting the game as a draw or declaring a winner, avoiding further processing.

Gameplay flow improvements:

  • Added a check in the step method to immediately return if the game is already marked as done, ensuring no further actions are processed.
  • Updated the step method to prevent calling self.state.step() after round-ending actions, avoiding player-switching issues.

Round and game-ending logic:

  • Enhanced _set_round_winner to directly end the game and declare a winner if the maximum number of rounds is reached, instead of waiting for another action.
  • Ensured that non-final rounds start immediately after announcing the round result, improving gameplay continuity.

Miscellaneous:

  • Updated _handle_showdown to use ta.GAME_ID as the sender ID for observations, ensuring consistency in game messages.

Copy link
Owner

@LeonGuertler LeonGuertler left a comment

Choose a reason for hiding this comment

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

Looks great! Two minor points:

  1. Do you think it would be possible to use the manually_update_current_player function instead of straight updating the attribute? In the state class, for example, player updates are prevented on invalid action, I worry the proposed changes my clash with that.

  2. Also, do you think we can solve the check for round completion differently than overwriting the get_observation function? Just to make sure future changes won't affect this unnecessarily.

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.

2 participants