From 5f6ba28685483d8660f8574de0ff6533724cd58b Mon Sep 17 00:00:00 2001 From: Leshem Choshen Date: Tue, 25 Feb 2025 09:49:51 -0500 Subject: [PATCH] Update env.py Poker prevent decreasing bet with [bet x] --- textarena/envs/two_player/Poker/env.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/textarena/envs/two_player/Poker/env.py b/textarena/envs/two_player/Poker/env.py index 5a779b2..d32cb86 100644 --- a/textarena/envs/two_player/Poker/env.py +++ b/textarena/envs/two_player/Poker/env.py @@ -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 elif raise_match: amount = int(raise_match.group(1)) return "raise", amount @@ -245,13 +248,20 @@ def _process_betting_action(self, player_id: int, action: str): action_type, bet_amount = self._parse_action(action) # 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 ] or [raise