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

Update env.py #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions textarena/envs/two_player/Poker/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ def _parse_action(self, action: str) -> Tuple[str, Optional[int]]:
return "call", None
elif bet_match:
amount = int(bet_match.group(1))
return "bet", amount
if amount >= self.state.game_state["current_bet"]:
return "bet", amount
else:
return "invalid_bet", None
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should also set invalid move with a reason ?

Copy link
Contributor

Choose a reason for hiding this comment

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

nvm just saw below haha

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I still think it isn't right to do this in the parsing function

elif raise_match:
amount = int(raise_match.group(1))
return "raise", amount
Expand All @@ -245,13 +248,20 @@ def _process_betting_action(self, player_id: int, action: str):
action_type, bet_amount = self._parse_action(action)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think you should do the check here, next to the other validity code... but otherwise this of course makes sense as a fix


# check if valid
if action_type == "invalid":
self.state.set_invalid_move(
player_id=player_id,
if "invalid" in action_type:
if "invalid_bet" == action_type:
reason = (
f"Player {player_id} did not provide a valid poker action.",
f"A placed bet cannot decrease the current bet."
)
else:
reason=(
f"Player {player_id} did not provide a valid poker action.",
f"You need to either [check], [fold], [call], [bet <amount>] or [raise <amount]."
)
self.state.set_invalid_move(
player_id=player_id,
reason=reason
)
return

Expand Down