Skip to content

Commit

Permalink
Solve issue when half pot smaller than call
Browse files Browse the repository at this point in the history
Former-commit-id: 9a3a839
  • Loading branch information
aypee19 committed Jan 12, 2021
1 parent f07b76b commit e6baa6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rlcard/games/nolimitholdem/round.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def get_nolimit_legal_actions(self, players):
if int(self.dealer.pot / 2) > player.remained_chips:
full_actions.remove(Action.RAISE_HALF_POT)

# Can't raise if the raise is smaller than pot
if int(self.dealer.pot / 2) + player.in_chips <= max(self.raised):
full_actions.remove(Action.RAISE_HALF_POT)

# If the current player has no more chips after call, we cannot raise
diff = max(self.raised) - self.raised[self.game_pointer]
if diff > 0 and player.in_chips + diff >= player.remained_chips:
Expand Down
3 changes: 2 additions & 1 deletion tests/games/test_nolimitholdem_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def test_raise_half_pot(self):
game = Game()

_, player_id = game.init_game()
game.step(Action.RAISE_HALF_POT)
self.assertNotIn(Action.RAISE_HALF_POT, game.get_legal_actions()) # Half pot equals call
game.step(Action.CALL)
step_raised = game.round.raised[player_id]
self.assertEqual(2, step_raised)

Expand Down

0 comments on commit e6baa6e

Please sign in to comment.