Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from cmu-dsc/safefailure
Browse files Browse the repository at this point in the history
Log error messages and timeout
  • Loading branch information
clementou authored Mar 29, 2024
2 parents 9696fc6 + 9efd768 commit bb48de3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
19 changes: 12 additions & 7 deletions engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,18 @@ def run_round(self, last_round: bool) -> None:
if player.game_clock <= 0:
self.log.append(f"{player.name} ran out of time.")
action = FoldAction()
try:
action = player.request_action(
hands[active], round_state.board, self.new_actions[active]
)
except TimeoutError:
self.log.append(f"{player.name} timed out.")
action = FoldAction()
else:
try:
action = player.request_action(
hands[active], round_state.board, self.new_actions[active]
)
except TimeoutError:
self.log.append(f"{player.name} timed out.")
action = FoldAction()
except Exception as e:
player.log.append(f"{[player.name]} raised an exception: {e}")
self.log.append(f"{player.name} raised an exception.")
action = FoldAction()

action = self._validate_action(action, round_state, player.name)
self.log_action(player.name, action, round_state)
Expand Down
5 changes: 4 additions & 1 deletion python_skeleton/skeleton/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def RequestAction(
"min_raise": self.round_state.raise_bounds()[0],
"max_raise": self.round_state.raise_bounds()[1],
}
action = self.pokerbot.get_action(observation)
try:
action = self.pokerbot.get_action(observation)
except Exception as e:
self.pokerbot.log.append(f"Error raised: {e}")
self.round_state = self.round_state.proceed(action)

return self._convert_action_to_response(action)
Expand Down

0 comments on commit bb48de3

Please sign in to comment.