Skip to content

Commit

Permalink
Solve all-in by call issue
Browse files Browse the repository at this point in the history
Former-commit-id: 85c3dc1
  • Loading branch information
aypee19 committed Jan 12, 2021
1 parent 6b5f73b commit 8e7badf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rlcard/games/nolimitholdem/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ def step(self, action):
self.game_pointer = self.round.proceed_round(self.players, action)

players_in_bypass = [1 if player.status in (PlayerStatus.FOLDED, PlayerStatus.ALLIN) else 0 for player in self.players]
if self.num_players - sum(players_in_bypass) == 1:
last_player = players_in_bypass.index(0)
if self.round.raised[last_player] >= max(self.round.raised):
# If the last player has put enough chips, he is also bypassed
players_in_bypass[last_player] = 1

# If a round is over, we deal more public cards
if self.round.is_over():
Expand Down
10 changes: 10 additions & 0 deletions tests/games/test_nolimitholdem_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ def test_payoffs_2(self):
self.assertEqual(2, len(game.get_payoffs()))
#self.assertListEqual([6.0, -6.0], game.get_payoffs())

def test_all_in_to_call(self):
game = Game()
game.init_chips = [50, 100]
game.dealer_id = 0
game.init_game()
game.step(Action.CALL)
game.step(Action.ALL_IN)
game.step(Action.CALL)
self.assertTrue(game.is_over())


if __name__ == '__main__':
unittest.main()

0 comments on commit 8e7badf

Please sign in to comment.